Skip to content

Commit

Permalink
Merge pull request #3521 from filecoin-project/conformance/tipset-act…
Browse files Browse the repository at this point in the history
…or-address

conformance: various changes
  • Loading branch information
magik6k authored Sep 4, 2020
2 parents d81feb0 + c723554 commit 2177fd5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
39 changes: 29 additions & 10 deletions conformance/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package conformance

import (
"context"
"fmt"

"github.com/filecoin-project/specs-actors/actors/crypto"

"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
Expand All @@ -12,7 +13,6 @@ import (
"github.com/filecoin-project/lotus/lib/blockstore"

"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/puppet"

"github.com/filecoin-project/test-vectors/chaos"
"github.com/filecoin-project/test-vectors/schema"
Expand Down Expand Up @@ -80,11 +80,14 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, preroot
}
switch msg.From.Protocol() {
case address.SECP256K1:
sb.SecpkMessages = append(sb.SecpkMessages, msg)
sb.SecpkMessages = append(sb.SecpkMessages, toChainMsg(msg))
case address.BLS:
sb.BlsMessages = append(sb.BlsMessages, msg)
sb.BlsMessages = append(sb.BlsMessages, toChainMsg(msg))
default:
return nil, fmt.Errorf("from account is not secpk nor bls: %s", msg.From)
// sneak in messages originating from other addresses as both kinds.
// these should fail, as they are actually invalid senders.
sb.SecpkMessages = append(sb.SecpkMessages, msg)
sb.BlsMessages = append(sb.BlsMessages, msg)
}
}
blocks = append(blocks, sb)
Expand Down Expand Up @@ -133,21 +136,37 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, preroot cid.Cid, epoch

invoker := vm.NewInvoker()

// add support for the puppet and chaos actors.
if puppetOn, ok := d.selector["puppet_actor"]; ok && puppetOn == "true" {
invoker.Register(puppet.PuppetActorCodeID, puppet.Actor{}, puppet.State{})
}
// register the chaos actor if required by the vector.
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
invoker.Register(chaos.ChaosActorCodeCID, chaos.Actor{}, chaos.State{})
}

lvm.SetInvoker(invoker)

ret, err := lvm.ApplyMessage(d.ctx, msg)
ret, err := lvm.ApplyMessage(d.ctx, toChainMsg(msg))
if err != nil {
return nil, cid.Undef, err
}

root, err := lvm.Flush(d.ctx)
return ret, root, err
}

// toChainMsg injects a synthetic 0-filled signature of the right length to
// messages that originate from secp256k senders, leaving all
// others untouched.
// TODO: generate a signature in the DSL so that it's encoded in
// the test vector.
func toChainMsg(msg *types.Message) (ret types.ChainMsg) {
ret = msg
if msg.From.Protocol() == address.SECP256K1 {
ret = &types.SignedMessage{
Message: *msg,
Signature: crypto.Signature{
Type: crypto.SigTypeSecp256k1,
Data: make([]byte, 65),
},
}
}
return ret
}
2 changes: 1 addition & 1 deletion extern/test-vectors
Submodule test-vectors updated 73 files
+15 −20 README.md
+54 −1 chaos/actor.go
+226 −0 chaos/cbor_gen.go
+2 −0 chaos/gen/gen.go
+5 −5 chaos/ids.go
+13 −13 corpus/actor_creation/addresses--sequential-10.json
+67 −0 corpus/actor_deletion/beneficiary--delete-w-balance-and-beneficiary.json
+58 −0 corpus/actor_deletion/no_beneficiary--delete-w-zero-balance.json
+72 −0 corpus/actor_deletion/x--beneficiary--fail-delete-w-balance-and-self-beneficiary.json
+5 −5 corpus/msg_application/actor_exec--msg-apply-fail-actor-execution-illegal-arg.json
+123 −0 corpus/msg_application/duplicates--messages-deduplicated.json
+196 −196 corpus/msg_application/gas_cost--msg-apply-fail-transfer-accountcreation-gas.json
+85 −0 corpus/msg_application/gas_cost--msg-ok-secp-bls-gas-costs.json
+8 −8 corpus/nested/nested_sends--fail-insufficient-funds-for-transfer-in-inner-send.json
+7 −7 corpus/paych/paych--collect-ok.json
+4 −4 corpus/paych/paych--create-ok.json
+5 −5 corpus/paych/paych--update-ok.json
+103 −0 corpus/reward/penalties--not-penalized-insufficient-balance-to-cover-gas-and-transfer.json
+111 −0 corpus/reward/penalties--not-penalized-insufficient-gas-for-return.json
+104 −0 corpus/reward/penalties--penalize-bad-nonce-multiple-miners.json
+104 −0 corpus/reward/penalties--penalize-inexistent-sender-multiple-miners.json
+112 −0 corpus/reward/penalties--penalize-insufficient-balance-to-cover-gas.json
+128 −0 corpus/reward/penalties--penalize-non-account-sender-multiple-miners.json
+10 −10 corpus/reward/reward--ok-miners-awarded-no-premiums.json
+4 −4 corpus/transfer/self_transfer--secp-to-id-addresses.json
+4 −4 corpus/transfer/self_transfer--secp-to-secp-addresses.json
+4 −4 corpus/transfer/system_receiver--to-burnt-funds-actor.json
+4 −4 corpus/transfer/system_receiver--to-cron-actor.json
+4 −4 corpus/transfer/system_receiver--to-init-actor.json
+4 −4 corpus/transfer/system_receiver--to-reward-actor.json
+4 −4 corpus/transfer/system_receiver--to-storage-market-actor.json
+4 −4 corpus/transfer/system_receiver--to-storage-power-actor.json
+4 −4 corpus/transfer/system_receiver--to-system-actor.json
+4 −4 corpus/transfer/system_receiver--to-verified-registry-actor.json
+7 −7 corpus/vm_violations/actor_creation--control-ok-with-good-address-good-cid.json
+7 −7 corpus/vm_violations/actor_creation--fails-with-existing-address.json
+7 −7 corpus/vm_violations/actor_creation--fails-with-good-addr-undef-cid.json
+7 −7 corpus/vm_violations/actor_creation--fails-with-undef-actor-cid-undef-addr.json
+7 −7 corpus/vm_violations/actor_creation--fails-with-unknown-actor-cid-undef-addr.json
+7 −7 corpus/vm_violations/actor_creation--fails-with-unknown-actor-cid.json
+7 −7 corpus/vm_violations/address_resolution--resolve-address-bad-id-identity.json
+7 −7 corpus/vm_violations/address_resolution--resolve-address-bls-lookup.json
+7 −7 corpus/vm_violations/address_resolution--resolve-address-id-identity.json
+7 −7 corpus/vm_violations/address_resolution--resolve-address-nonexistant.json
+7 −7 corpus/vm_violations/address_resolution--resolve-address-secp-lookup.json
+7 −7 corpus/vm_violations/caller_validation--nil-allowed-address-set.json
+7 −7 corpus/vm_violations/caller_validation--nil-allowed-type-set.json
+7 −7 corpus/vm_violations/caller_validation--none.json
+7 −7 corpus/vm_violations/caller_validation--twice.json
+60 −27 gen/builders/actors.go
+8 −0 gen/builders/asserter.go
+10 −12 gen/builders/builder_tipset.go
+20 −17 gen/builders/gas.go
+1 −1 gen/builders/messages.go
+5 −10 gen/builders/messages_typed.go
+1 −1 gen/builders/predicates.go
+2 −2 gen/builders/wallet.go
+138 −0 gen/suites/actor_deletion/main.go
+47 −0 gen/suites/msg_application/duplicates.go
+31 −0 gen/suites/msg_application/gas_cost.go
+19 −0 gen/suites/msg_application/main.go
+1 −1 gen/suites/multisig/ok.go
+1 −1 gen/suites/nested/main.go
+14 −28 gen/suites/nested/nested.go
+128 −0 gen/suites/reward/main.go
+3 −0 gen/suites/reward/miner.go
+94 −0 gen/suites/reward/penalties.go
+5 −7 gen/suites/transfer/main.go
+2 −3 gen/suites/transfer/system_receiver.go
+2 −2 gen/suites/vm_violations/main.go
+1 −1 go.mod
+3 −0 go.sum
+1 −1 schema/schema.go
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/filecoin-project/specs-actors v0.9.3
github.com/filecoin-project/specs-storage v0.1.1-0.20200730063404-f7db367e9401
github.com/filecoin-project/statediff v0.0.1
github.com/filecoin-project/test-vectors v0.0.0-20200902131127-9806d09b005d
github.com/filecoin-project/test-vectors v0.0.0-20200903223506-84da0a5ea125
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/go-kit/kit v0.10.0
github.com/google/uuid v1.1.1
Expand Down
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZO
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg=
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
github.com/filecoin-project/lotus v0.4.3-0.20200820203717-d1718369a182/go.mod h1:biFZPQ/YyQGfkHUmHMiaNf2hnD6zm1+OAXPQYQ61Zkg=
github.com/filecoin-project/lotus v0.5.8-0.20200902130912-0962292f920e/go.mod h1:OkZ5aUqs+fFnJOq9243WJDsTa9c3/Ae67NIAwVhAB+0=
github.com/filecoin-project/lotus v0.5.8-0.20200903221953-ada5e6ae68cf/go.mod h1:wxuzS4ozpCFThia18G+J5P0Jp/DSiq9ezzJF1yvZuP4=
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo=
github.com/filecoin-project/sector-storage v0.0.0-20200730050024-3ee28c3b6d9a/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA=
github.com/filecoin-project/sector-storage v0.0.0-20200810171746-eac70842d8e0 h1:E1fZ27fhKK05bhZItfTwqr1i05vXnEZJznQFEYwEEUU=
Expand Down

0 comments on commit 2177fd5

Please sign in to comment.