Merge pull request #98 from filecoin-project/feat/method-id-bump
start method IDs at 1, to allow 0 for basic transfers
This commit is contained in:
commit
f712f56c6d
@ -43,10 +43,16 @@ type InitActorState struct {
|
|||||||
NextID uint64
|
NextID uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type iAMethods struct {
|
||||||
|
Exec uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
var IAMethods = iAMethods{2}
|
||||||
|
|
||||||
func (ia InitActor) Exports() []interface{} {
|
func (ia InitActor) Exports() []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
nil,
|
1: nil,
|
||||||
ia.Exec,
|
2: ia.Exec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +140,8 @@ func (ia InitActor) Exec(act *types.Actor, vmctx types.VMContext, p *ExecParams)
|
|||||||
return nil, aerrors.Escalate(err, "inserting new actor into state tree")
|
return nil, aerrors.Escalate(err, "inserting new actor into state tree")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = vmctx.Send(idAddr, 0, vmctx.Message().Value, p.Params)
|
// '1' is reserved for constructor methods
|
||||||
|
_, err = vmctx.Send(idAddr, 1, vmctx.Message().Value, p.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -89,22 +89,41 @@ type StorageMinerConstructorParams struct {
|
|||||||
PeerID peer.ID
|
PeerID peer.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type maMethods struct {
|
||||||
|
Constructor uint64
|
||||||
|
CommitSector uint64
|
||||||
|
SubmitPost uint64
|
||||||
|
SlashStorageFault uint64
|
||||||
|
GetCurrentProvingSet uint64
|
||||||
|
ArbitrateDeal uint64
|
||||||
|
DePledge uint64
|
||||||
|
GetOwner uint64
|
||||||
|
GetWorkerAddr uint64
|
||||||
|
GetPower uint64
|
||||||
|
GetPeerID uint64
|
||||||
|
GetSectorSize uint64
|
||||||
|
UpdatePeerID uint64
|
||||||
|
ChangeWorker uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
var MAMethods = maMethods{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
|
||||||
|
|
||||||
func (sma StorageMinerActor) Exports() []interface{} {
|
func (sma StorageMinerActor) Exports() []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
0: sma.StorageMinerConstructor,
|
1: sma.StorageMinerConstructor,
|
||||||
1: sma.CommitSector,
|
2: sma.CommitSector,
|
||||||
//2: sma.SubmitPost,
|
//3: sma.SubmitPost,
|
||||||
//3: sma.SlashStorageFault,
|
//4: sma.SlashStorageFault,
|
||||||
//4: sma.GetCurrentProvingSet,
|
//5: sma.GetCurrentProvingSet,
|
||||||
//5: sma.ArbitrateDeal,
|
//6: sma.ArbitrateDeal,
|
||||||
//6: sma.DePledge,
|
//7: sma.DePledge,
|
||||||
//7: sma.GetOwner,
|
//8: sma.GetOwner,
|
||||||
//8: sma.GetWorkerAddr,
|
//9: sma.GetWorkerAddr,
|
||||||
9: sma.GetPower,
|
10: sma.GetPower,
|
||||||
//10: sma.GetPeerID,
|
//11: sma.GetPeerID,
|
||||||
//11: sma.GetSectorSize,
|
//12: sma.GetSectorSize,
|
||||||
//12: sma.UpdatePeerID,
|
//13: sma.UpdatePeerID,
|
||||||
//13: sma.ChangeWorker,
|
//14: sma.ChangeWorker,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,16 +20,28 @@ func init() {
|
|||||||
|
|
||||||
type StorageMarketActor struct{}
|
type StorageMarketActor struct{}
|
||||||
|
|
||||||
|
type smaMethods struct {
|
||||||
|
Constructor uint64
|
||||||
|
CreateStorageMiner uint64
|
||||||
|
SlashConsensusFault uint64
|
||||||
|
UpdateStorage uint64
|
||||||
|
GetTotalStorage uint64
|
||||||
|
PowerLookup uint64
|
||||||
|
IsMiner uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
var SMAMethods = smaMethods{1, 2, 3, 4, 5, 6, 7}
|
||||||
|
|
||||||
func (sma StorageMarketActor) Exports() []interface{} {
|
func (sma StorageMarketActor) Exports() []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
//0: sma.StorageMarketConstructor,
|
//1: sma.StorageMarketConstructor,
|
||||||
1: sma.CreateStorageMiner,
|
2: sma.CreateStorageMiner,
|
||||||
//2: sma.SlashConsensusFault,
|
//3: sma.SlashConsensusFault,
|
||||||
3: sma.UpdateStorage,
|
4: sma.UpdateStorage,
|
||||||
4: sma.GetTotalStorage,
|
5: sma.GetTotalStorage,
|
||||||
5: sma.PowerLookup,
|
6: sma.PowerLookup,
|
||||||
6: sma.IsMiner,
|
7: sma.IsMiner,
|
||||||
//7: sma.StorageCollateralForSize,
|
//8: sma.StorageCollateralForSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +72,7 @@ func (sma StorageMarketActor) CreateStorageMiner(act *types.Actor, vmctx types.V
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := vmctx.Send(InitActorAddress, 1, vmctx.Message().Value, encoded)
|
ret, err := vmctx.Send(InitActorAddress, IAMethods.Exec, vmctx.Message().Value, encoded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -139,7 +151,7 @@ func (sma StorageMarketActor) PowerLookup(act *types.Actor, vmctx types.VMContex
|
|||||||
return nil, aerrors.New(1, "miner not registered with storage market")
|
return nil, aerrors.New(1, "miner not registered with storage market")
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, err := vmctx.Send(params.Miner, 9, types.NewInt(0), EmptyStructCBOR)
|
ret, err := vmctx.Send(params.Miner, MAMethods.GetPower, types.NewInt(0), EmptyStructCBOR)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, aerrors.Wrap(err, "invoke Miner.GetPower")
|
return nil, aerrors.Wrap(err, "invoke Miner.GetPower")
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ func TestStorageMarketCreateMiner(t *testing.T) {
|
|||||||
M: types.Message{
|
M: types.Message{
|
||||||
To: StorageMarketAddress,
|
To: StorageMarketAddress,
|
||||||
From: h.From,
|
From: h.From,
|
||||||
Method: 1,
|
Method: SMAMethods.CreateStorageMiner,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
@ -55,7 +55,7 @@ func TestStorageMarketCreateMiner(t *testing.T) {
|
|||||||
M: types.Message{
|
M: types.Message{
|
||||||
To: StorageMarketAddress,
|
To: StorageMarketAddress,
|
||||||
From: h.From,
|
From: h.From,
|
||||||
Method: 6,
|
Method: SMAMethods.IsMiner,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
@ -81,7 +81,7 @@ func TestStorageMarketCreateMiner(t *testing.T) {
|
|||||||
M: types.Message{
|
M: types.Message{
|
||||||
To: StorageMarketAddress,
|
To: StorageMarketAddress,
|
||||||
From: h.From,
|
From: h.From,
|
||||||
Method: 5,
|
Method: SMAMethods.PowerLookup,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
|
@ -78,7 +78,7 @@ func TestVMInvokeMethod(t *testing.T) {
|
|||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: InitActorAddress,
|
To: InitActorAddress,
|
||||||
From: from,
|
From: from,
|
||||||
Method: 1,
|
Method: IAMethods.Exec,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
@ -122,7 +122,7 @@ func TestStorageMarketActorCreateMiner(t *testing.T) {
|
|||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: StorageMarketAddress,
|
To: StorageMarketAddress,
|
||||||
From: from,
|
From: from,
|
||||||
Method: 1,
|
Method: SMAMethods.CreateStorageMiner,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
|
@ -64,7 +64,7 @@ func NewHarness(t *testing.T) *Harness {
|
|||||||
|
|
||||||
h.cs = store.NewChainStore(h.bs, nil)
|
h.cs = store.NewChainStore(h.bs, nil)
|
||||||
|
|
||||||
h.vm, err = vm.NewVM(stateroot, 1, maddr, h.cs)
|
h.vm, err = vm.NewVM(stateroot, IAMethods.Exec, maddr, h.cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func TestVMInvokeHarness(t *testing.T) {
|
|||||||
M: types.Message{
|
M: types.Message{
|
||||||
To: InitActorAddress,
|
To: InitActorAddress,
|
||||||
From: h.From,
|
From: h.From,
|
||||||
Method: 1,
|
Method: IAMethods.Exec,
|
||||||
Params: h.DumpObject(
|
Params: h.DumpObject(
|
||||||
&ExecParams{
|
&ExecParams{
|
||||||
Code: StorageMinerCodeCid,
|
Code: StorageMinerCodeCid,
|
||||||
|
@ -75,7 +75,7 @@ var createMinerCmd = &cli.Command{
|
|||||||
msg := types.Message{
|
msg := types.Message{
|
||||||
To: actors.StorageMarketAddress,
|
To: actors.StorageMarketAddress,
|
||||||
From: addr,
|
From: addr,
|
||||||
Method: 1, // TODO: constants pls
|
Method: actors.SMAMethods.CreateStorageMiner,
|
||||||
Params: params,
|
Params: params,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
|
@ -125,7 +125,7 @@ var initCmd = &cli.Command{
|
|||||||
|
|
||||||
Value: collateral,
|
Value: collateral,
|
||||||
|
|
||||||
Method: 1, // TODO: Review: do we have a reverse index with these anywhere? (actor_storageminer.go)
|
Method: actors.SMAMethods.CreateStorageMiner,
|
||||||
Params: params,
|
Params: params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user