self review, cleanup
This commit is contained in:
parent
74f68dc630
commit
bc7f86ef05
@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("gen")
|
var log = logging.Logger("gen")
|
||||||
|
|
||||||
const msgsPerBlock = 2
|
const msgsPerBlock = 20
|
||||||
|
|
||||||
type ChainGen struct {
|
type ChainGen struct {
|
||||||
accounts []address.Address
|
accounts []address.Address
|
||||||
@ -128,14 +128,6 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
PeerIDs: []peer.ID{"peerID1", "peerID2"},
|
PeerIDs: []peer.ID{"peerID1", "peerID2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
minercfg := &GenMinerCfg{
|
|
||||||
Workers: []address.Address{worker},
|
|
||||||
Owners: []address.Address{worker},
|
|
||||||
PeerIDs: []peer.ID{"peerID1"},
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{
|
genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{
|
||||||
worker: types.NewInt(50000),
|
worker: types.NewInt(50000),
|
||||||
banker: types.NewInt(90000000),
|
banker: types.NewInt(90000000),
|
||||||
@ -286,7 +278,6 @@ func (cg *ChainGen) NextTipSet() (*MinedTipSet, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cg.curTipset = store.NewFullTipSet(blks)
|
cg.curTipset = store.NewFullTipSet(blks)
|
||||||
fmt.Printf("Mined tipset %s (%d) on top of %s (%d)\n", cg.curTipset.Cids(), cg.curTipset.TipSet().Height(), base.Cids(), base.Height())
|
|
||||||
|
|
||||||
return &MinedTipSet{
|
return &MinedTipSet{
|
||||||
TipSet: cg.curTipset,
|
TipSet: cg.curTipset,
|
||||||
@ -298,7 +289,6 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, eproof t
|
|||||||
|
|
||||||
ts := parents.MinTimestamp() + (uint64(len(tickets)) * build.BlockDelay)
|
ts := parents.MinTimestamp() + (uint64(len(tickets)) * build.BlockDelay)
|
||||||
|
|
||||||
fmt.Println("Make block: ", parents.Height(), len(tickets))
|
|
||||||
fblk, err := MinerCreateBlock(context.TODO(), cg.sm, cg.w, m, parents, tickets, eproof, msgs, ts)
|
fblk, err := MinerCreateBlock(context.TODO(), cg.sm, cg.w, m, parents, tickets, eproof, msgs, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package gen
|
package gen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ func testGeneration(t testing.TB, n int, msgs int) {
|
|||||||
|
|
||||||
var height int
|
var height int
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
fmt.Println("LOOP: ", i)
|
|
||||||
mts, err := g.NextTipSet()
|
mts, err := g.NextTipSet()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error at H:%d, %s", i, err)
|
t.Fatalf("error at H:%d, %s", i, err)
|
||||||
|
@ -2,7 +2,6 @@ package gen
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
bls "github.com/filecoin-project/go-bls-sigs"
|
bls "github.com/filecoin-project/go-bls-sigs"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
@ -25,7 +24,6 @@ func MinerCreateBlock(ctx context.Context, sm *stmgr.StateManager, w *wallet.Wal
|
|||||||
return nil, errors.Wrap(err, "failed to load tipset state")
|
return nil, errors.Wrap(err, "failed to load tipset state")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("HEIGHT CALC: ", parents.Height(), len(tickets))
|
|
||||||
height := parents.Height() + uint64(len(tickets))
|
height := parents.Height() + uint64(len(tickets))
|
||||||
|
|
||||||
vmi, err := vm.NewVM(st, height, miner, sm.ChainStore())
|
vmi, err := vm.NewVM(st, height, miner, sm.ChainStore())
|
||||||
|
@ -89,7 +89,6 @@ func (sm *StateManager) computeTipSetState(cids []cid.Cid) (cid.Cid, error) {
|
|||||||
|
|
||||||
bms, sms, err := sm.cs.MessagesForBlock(b)
|
bms, sms, err := sm.cs.MessagesForBlock(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("stop a sec: " + err.Error())
|
|
||||||
return cid.Undef, xerrors.Errorf("failed to get messages for block: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to get messages for block: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +46,6 @@ func (ts *TipSet) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTipSet(blks []*BlockHeader) (*TipSet, error) {
|
func NewTipSet(blks []*BlockHeader) (*TipSet, error) {
|
||||||
/*
|
|
||||||
sort.Slice(blks, func(i, j int) bool {
|
|
||||||
a := blks[i].LastTicket()
|
|
||||||
b := blks[j].LastTicket()
|
|
||||||
return bytes.Compare(a.VDFResult, b.VDFResult) < 0
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
var ts TipSet
|
var ts TipSet
|
||||||
ts.cids = []cid.Cid{blks[0].Cid()}
|
ts.cids = []cid.Cid{blks[0].Cid()}
|
||||||
ts.blks = blks
|
ts.blks = blks
|
||||||
|
@ -41,8 +41,6 @@ func (inv *invoker) Invoke(act *types.Actor, vmctx types.VMContext, method uint6
|
|||||||
|
|
||||||
code, ok := inv.builtInCode[act.Code]
|
code, ok := inv.builtInCode[act.Code]
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Println("bad code? ", act.Code)
|
|
||||||
fmt.Println("miner actor code cid: ", actors.StorageMinerCodeCid)
|
|
||||||
return nil, aerrors.Newf(255, "no code for actor %s", act.Code)
|
return nil, aerrors.Newf(255, "no code for actor %s", act.Code)
|
||||||
}
|
}
|
||||||
if method >= uint64(len(code)) || code[method] == nil {
|
if method >= uint64(len(code)) || code[method] == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user