diff --git a/pkg/events/filter/index.go b/pkg/events/filter/index.go index a1dbce257f..2a0eb9df94 100644 --- a/pkg/events/filter/index.go +++ b/pkg/events/filter/index.go @@ -152,7 +152,10 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever } isIndexedValue := func(b uint8) bool { - return b&types.EventFlagIndexedValue == types.EventFlagIndexedValue + // currently we mark the full entry as indexed if either the key + // or the value are indexed; in the future we will need finer-grained + // management of indices + return b&(types.EventFlagIndexedKey|types.EventFlagIndexedValue) > 0 } for msgIdx, em := range ems { diff --git a/pkg/wallet/key/keyinfo_test.go b/pkg/wallet/key/keyinfo_test.go index 25ac9be1bf..c72dfbf8bd 100644 --- a/pkg/wallet/key/keyinfo_test.go +++ b/pkg/wallet/key/keyinfo_test.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "encoding/hex" "encoding/json" + "flag" "fmt" "testing" @@ -20,6 +21,12 @@ import ( "github.com/filecoin-project/venus/pkg/crypto" ) +// copy from `github.com/filecoin-project/venus/pkg/testhelpers/testflags`,avoid `import cycle not allowed` +var ( + integrationTest = flag.Bool("integration", true, "Run the integration go tests") // nolint + unitTest = flag.Bool("unit", true, "Run the unit go tests") // nolint +) + func TestKeyInfoAddress(t *testing.T) { prv, _ := hex.DecodeString("2a2a2a2a2a2a2a2a5fbf0ed0f8364c01ff27540ecd6669ff4cc548cbe60ef5ab") ki := &KeyInfo{ diff --git a/venus-shared/types/eth_transactions_test.go b/venus-shared/types/eth_transactions_test.go index 6600ddb693..82cf8c6412 100644 --- a/venus-shared/types/eth_transactions_test.go +++ b/venus-shared/types/eth_transactions_test.go @@ -19,6 +19,7 @@ import ( crypto1 "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/venus/pkg/crypto" + _ "github.com/filecoin-project/venus/pkg/crypto/delegated" "github.com/filecoin-project/venus/venus-shared/actors" ) diff --git a/venus-shared/types/rlp.go b/venus-shared/types/rlp.go index 332f286981..bbb0cecb91 100644 --- a/venus-shared/types/rlp.go +++ b/venus-shared/types/rlp.go @@ -9,14 +9,14 @@ import ( // maxListElements restricts the amount of RLP list elements we'll read. // The ETH API only ever reads EIP-1559 transactions, which are bounded by // 12 elements exactly, so we play it safe and set exactly that limit here. -const maxListElements = 500 +const maxListElements = 12 func EncodeRLP(val interface{}) ([]byte, error) { return encodeRLP(val) } func encodeRLPListItems(list []interface{}) (result []byte, err error) { - var res []byte + res := []byte{} for _, elem := range list { encoded, err := encodeRLP(elem) if err != nil { @@ -163,7 +163,7 @@ func decodeLength(data []byte, lenInBytes int) (length int, err error) { func decodeListElems(data []byte, length int) (res []interface{}, err error) { totalConsumed := 0 - var result []interface{} + result := []interface{}{} for i := 0; totalConsumed < length && i < maxListElements; i++ { elem, consumed, err := decodeRLP(data[totalConsumed:]) diff --git a/venus-shared/utils/method_map_test.go b/venus-shared/utils/method_map_test.go index 497aa8a498..a37e323cbe 100644 --- a/venus-shared/utils/method_map_test.go +++ b/venus-shared/utils/method_map_test.go @@ -1,11 +1,15 @@ package utils import ( + "fmt" "testing" + actortypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/manifest" tf "github.com/filecoin-project/venus/pkg/testhelpers/testflags" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/types" + "github.com/ipfs/go-cid" "github.com/stretchr/testify/assert" ) @@ -15,9 +19,8 @@ func TestMethodMap(t *testing.T) { t.Run("Default to load mainnet actors", func(t *testing.T) { for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata { if actorsMetadata.Network == string(types.NetworkNameMain) { - for _, actor := range actorsMetadata.Actors { - _, ok := MethodsMap[actor] - assert.True(t, ok) + for name, actor := range actorsMetadata.Actors { + checkActorCode(t, actorsMetadata.Version, actor, name, actorsMetadata.Network) } } } @@ -28,11 +31,34 @@ func TestMethodMap(t *testing.T) { ReloadMethodsMap() for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata { if actorsMetadata.Network == string(types.NetworkNameButterfly) { - for _, actor := range actorsMetadata.Actors { - _, ok := MethodsMap[actor] - assert.True(t, ok) + for name, actor := range actorsMetadata.Actors { + checkActorCode(t, actorsMetadata.Version, actor, name, actorsMetadata.Network) } } } }) } + +func checkActorCode(t *testing.T, actorVersion actortypes.Version, actorCode cid.Cid, actorName, networkName string) { + actorKeysWithVersion := map[string]actortypes.Version{ + manifest.EamKey: actortypes.Version10, + manifest.EvmKey: actortypes.Version10, + manifest.PlaceholderKey: actortypes.Version10, + manifest.EthAccountKey: actortypes.Version10, + } + + ver, ok := actorKeysWithVersion[actorName] + if ok { + if actorVersion < ver { + return + } + } + + _, ok = MethodsMap[actorCode] + comment := fmt.Sprintf("actor %s not found: %s %d %s", actorCode, networkName, actorVersion, actorName) + assert.Truef(t, ok, comment) + + res, ok := actors.GetActorCodeID(actorVersion, actorName) + assert.Truef(t, ok, comment) + assert.Equalf(t, actorCode, res, "actor not found: name %s expect %s, actual %s", actorName, actorCode, res) +} diff --git a/venus-shared/utils/utils_test.go b/venus-shared/utils/utils_test.go index 9fea556323..97da382d46 100644 --- a/venus-shared/utils/utils_test.go +++ b/venus-shared/utils/utils_test.go @@ -45,19 +45,17 @@ func TestLoadBuiltinActors(t *testing.T) { full := mock.NewMockFullNode(ctrl) for nn := range NetworkNameWithNetworkType { - full.EXPECT().StateNetworkName(ctx).Return(nn, nil) + if nn == types.NetworkNameWallaby || nn == types.NetworkNameHyperspace { + continue + } + full.EXPECT().StateNetworkName(ctx).Return(nn, nil) assert.Nil(t, LoadBuiltinActors(ctx, full)) for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata { if actorsMetadata.Network == string(nn) { for name, actor := range actorsMetadata.Actors { - res, ok := actors.GetActorCodeID(actorsMetadata.Version, name) - assert.True(t, ok) - assert.Equal(t, actor, res) - - _, ok2 := MethodsMap[actor] - assert.True(t, ok2) + checkActorCode(t, actorsMetadata.Version, actor, name, actorsMetadata.Network) } } }