diff --git a/example/access_ticket/main.go b/example/access_ticket/main.go index 9a6a2c30..216a1da6 100644 --- a/example/access_ticket/main.go +++ b/example/access_ticket/main.go @@ -81,7 +81,7 @@ func runDemo(chainId string, nodeAddr string, validatorKeyName string) { record := registerObject(ctx, client, &txBuilder, txSigner, policy.Id) log.Printf("Evaluating Access Request to read file:readme") - decision := checkAccess(ctx, client, &txBuilder, txSigner, policy.Id, record.Metadata.Creator.Identifier, []*acptypes.Operation{ + decision := checkAccess(ctx, client, &txBuilder, txSigner, policy.Id, record.Metadata.OwnerDid, []*acptypes.Operation{ { Object: coretypes.NewObject("file", "readme"), Permission: "read", @@ -133,7 +133,7 @@ func getSigner(accAddr string) sdk.TxSigner { func createPolicy(ctx context.Context, client *sdk.Client, txBuilder *sdk.TxBuilder, txSigner sdk.TxSigner) *coretypes.Policy { msgSet := sdk.MsgSet{} - policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicyNow(txSigner.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) + policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicy(txSigner.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) tx, err := txBuilder.Build(ctx, txSigner, &msgSet) if err != nil { log.Fatal(err) @@ -157,14 +157,14 @@ func createPolicy(ctx context.Context, client *sdk.Client, txBuilder *sdk.TxBuil log.Fatal(err) } - log.Printf("policy created: %v", policyResponse.Policy.Id) - return policyResponse.Policy + log.Printf("policy created: %v", policyResponse.Record.Policy.Id) + return policyResponse.Record.Policy } -func registerObject(ctx context.Context, client *sdk.Client, txBuilder *sdk.TxBuilder, txSigner sdk.TxSigner, policyId string) *coretypes.RelationshipRecord { +func registerObject(ctx context.Context, client *sdk.Client, txBuilder *sdk.TxBuilder, txSigner sdk.TxSigner, policyId string) *acptypes.RelationshipRecord { msgSet := sdk.MsgSet{} mapper := msgSet.WithDirectPolicyCmd( - acptypes.NewMsgDirectPolicyCmdNow( + acptypes.NewMsgDirectPolicyCmd( txSigner.GetAccAddress(), policyId, acptypes.NewRegisterObjectCmd(coretypes.NewObject("file", "readme")), diff --git a/example/bearer_auth/main.go b/example/bearer_auth/main.go index b6583910..d7b42a6b 100644 --- a/example/bearer_auth/main.go +++ b/example/bearer_auth/main.go @@ -8,7 +8,6 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocdc "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" - prototypes "github.com/cosmos/gogoproto/types" coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/sourcenetwork/sourcehub/sdk" @@ -57,7 +56,7 @@ resources: ` msgSet := sdk.MsgSet{} - policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicyNow(txSigner.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) + policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicy(txSigner.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) tx, err := txBuilder.Build(ctx, txSigner, &msgSet) if err != nil { log.Fatal(err) @@ -81,7 +80,7 @@ resources: log.Fatal(err) } - log.Printf("policy created: %v", policyResponse.Policy.Id) + log.Printf("policy created: %v", policyResponse.Record.Policy.Id) alice, signer, err := did.ProduceDID() if err != nil { @@ -99,11 +98,10 @@ resources: log.Printf("alice's JWS: %v", jws) bearerCmd := acptypes.MsgBearerPolicyCmd{ - Creator: txSigner.GetAccAddress(), - BearerToken: jws, - PolicyId: policyResponse.Policy.Id, - Cmd: acptypes.NewRegisterObjectCmd(coretypes.NewObject("resource", "foo")), - CreationTime: prototypes.TimestampNow(), + Creator: txSigner.GetAccAddress(), + BearerToken: jws, + PolicyId: policyResponse.Record.Policy.Id, + Cmd: acptypes.NewRegisterObjectCmd(coretypes.NewObject("resource", "foo")), } log.Printf("Bearer Cmd: %v", bearerCmd) diff --git a/example/sdk/main.go b/example/sdk/main.go index ffc5582d..dedab380 100644 --- a/example/sdk/main.go +++ b/example/sdk/main.go @@ -60,7 +60,7 @@ resources: ` msgSet := sdk.MsgSet{} - policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicyNow(signer.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) + policyMapper := msgSet.WithCreatePolicy(acptypes.NewMsgCreatePolicy(signer.GetAccAddress(), policy, coretypes.PolicyMarshalingType_SHORT_YAML)) tx, err := txBuilder.Build(ctx, signer, &msgSet) if err != nil { log.Fatal(err) @@ -92,7 +92,7 @@ resources: log.Fatal(err) } cmdBuilder.PolicyCmd(acptypes.NewRegisterObjectCmd(coretypes.NewObject("resource", "readme.txt"))) - cmdBuilder.PolicyID(policyResponse.Policy.Id) + cmdBuilder.PolicyID(policyResponse.Record.Policy.Id) cmdBuilder.Actor(aliceDid) cmdBuilder.SetSigner(aliceSigner) jws, err := cmdBuilder.BuildJWS(ctx) diff --git a/proto/sourcehub/acp/access_decision.proto b/proto/sourcehub/acp/access_decision.proto index d96e3745..74fa1f77 100644 --- a/proto/sourcehub/acp/access_decision.proto +++ b/proto/sourcehub/acp/access_decision.proto @@ -4,6 +4,7 @@ package sourcehub.acp; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "sourcenetwork/acp_core/relationship.proto"; +import "sourcehub/acp/time.proto"; option go_package = "github.com/sourcenetwork/sourcehub/x/acp/types"; @@ -23,7 +24,7 @@ message AccessDecision { DecisionParams params = 7; // used as part of id generation - google.protobuf.Timestamp creation_time = 8; + Timestamp creation_time = 8; // issued_height stores the block height when the Decision was evaluated uint64 issued_height = 9; diff --git a/proto/sourcehub/acp/policy_cmd.proto b/proto/sourcehub/acp/policy_cmd.proto index e1006f81..68efb05e 100644 --- a/proto/sourcehub/acp/policy_cmd.proto +++ b/proto/sourcehub/acp/policy_cmd.proto @@ -96,16 +96,9 @@ message RevealRegistrationCmd { RegistrationProof proof = 2; } -enum RevealRegistrationResult { - NO_OP = 0; - CREATED = 1; - AMENDED = 2; -} - message RevealRegistrationCmdResult { - RevealRegistrationResult result = 1; - RelationshipRecord record = 2; - ObjectRegistrationEvent event = 3; + RelationshipRecord record = 1; + ObjectRegistrationEvent event = 2; } message FlagHijackAttemptCmd { diff --git a/proto/sourcehub/acp/tx.proto b/proto/sourcehub/acp/tx.proto index c0c85dda..f485d0a7 100644 --- a/proto/sourcehub/acp/tx.proto +++ b/proto/sourcehub/acp/tx.proto @@ -76,7 +76,6 @@ message MsgCreatePolicy { string creator = 1; string policy = 2; sourcenetwork.acp_core.PolicyMarshalingType marshal_type = 3; - google.protobuf.Timestamp creation_time = 4; } message MsgCreatePolicyResponse { @@ -87,8 +86,7 @@ message MsgCheckAccess { option (cosmos.msg.v1.signer) = "creator"; string creator = 1; string policy_id = 2; - google.protobuf.Timestamp creation_time = 3; - AccessRequest access_request = 4; + AccessRequest access_request = 3; } message MsgCheckAccessResponse { @@ -116,7 +114,6 @@ message MsgBearerPolicyCmd { string bearer_token = 2; string policy_id = 3; PolicyCmd cmd = 4; - google.protobuf.Timestamp creation_time = 5; } message MsgBearerPolicyCmdResponse { @@ -128,7 +125,6 @@ message MsgDirectPolicyCmd { string creator = 1; string policy_id = 2; PolicyCmd cmd = 3; - google.protobuf.Timestamp creation_time = 4; } message MsgDirectPolicyCmdResponse { diff --git a/tests/e2e/sdk/sdk_test.go b/tests/e2e/sdk/sdk_test.go index 8f74f401..0d42ba36 100644 --- a/tests/e2e/sdk/sdk_test.go +++ b/tests/e2e/sdk/sdk_test.go @@ -34,7 +34,7 @@ name: test policy ` msgSet := sdk.MsgSet{} mapper := msgSet.WithCreatePolicy( - types.NewMsgCreatePolicyNow( + types.NewMsgCreatePolicy( network.GetValidatorAddr(), policy, coretypes.PolicyMarshalingType_SHORT_YAML, diff --git a/tests/integration/acp/actions.go b/tests/integration/acp/actions.go index a18bd027..105f1150 100644 --- a/tests/integration/acp/actions.go +++ b/tests/integration/acp/actions.go @@ -4,7 +4,7 @@ import ( coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/stretchr/testify/require" - "github.com/sourcenetwork/sourcehub/x/acp/registration" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -17,24 +17,18 @@ type CreatePolicyAction struct { func (a *CreatePolicyAction) Run(ctx *TestCtx) *coretypes.Policy { msg := &types.MsgCreatePolicy{ - Policy: a.Policy, - Creator: a.Creator.SourceHubAddr, - MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, - CreationTime: TimeToProto(ctx.Timestamp), + Policy: a.Policy, + Creator: a.Creator.SourceHubAddr, + MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, } response, err := ctx.Executor.CreatePolicy(ctx, msg) - var expected any = nil - if a.Expected != nil { - expected = &types.MsgCreatePolicyResponse{ - Policy: a.Expected, - } - } - AssertResults(ctx, response, expected, err, a.ExpectedErr) + AssertError(ctx, err, a.ExpectedErr) if response != nil { + require.Equal(ctx.T, a.Expected, response.Record.Policy) ctx.State.PolicyCreator = a.Creator.SourceHubAddr - ctx.State.PolicyId = response.Policy.Id - return response.Policy + ctx.State.PolicyId = response.Record.Policy.Id + return response.Record.Policy } return nil } @@ -47,13 +41,14 @@ type SetRelationshipAction struct { ExpectedErr error } -func (a *SetRelationshipAction) Run(ctx *TestCtx) *coretypes.RelationshipRecord { +func (a *SetRelationshipAction) Run(ctx *TestCtx) *types.RelationshipRecord { cmd := types.NewSetRelationshipCmd(a.Relationship) result, err := dispatchPolicyCmd(ctx, a.PolicyId, a.Actor, cmd) got := (*types.SetRelationshipCmdResult)(nil) if result != nil { got = result.GetSetRelationshipResult() } + AssertResults(ctx, got, a.Expected, err, a.ExpectedErr) if got != nil { return got.Record @@ -69,7 +64,7 @@ type RegisterObjectAction struct { ExpectedErr error } -func (a *RegisterObjectAction) Run(ctx *TestCtx) *coretypes.RelationshipRecord { +func (a *RegisterObjectAction) Run(ctx *TestCtx) *types.RelationshipRecord { cmd := types.NewRegisterObjectCmd(a.Object) result, err := dispatchPolicyCmd(ctx, a.PolicyId, a.Actor, cmd) got := (*types.RegisterObjectCmdResult)(nil) @@ -209,7 +204,7 @@ func (a *PolicySetupAction) Run(ctx *TestCtx) { type GetPolicyAction struct { Id string - Expected *types.QueryPolicyResponse + Expected *types.PolicyRecord ExpectedErr error } @@ -233,7 +228,7 @@ type CommitRegistrationsAction struct { func (a *CommitRegistrationsAction) Run(ctx *TestCtx) *types.RegistrationsCommitment { actor := coretypes.NewActor(a.Actor.DID) - commitment, err := registration.GenerateCommitmentWithoutValidation(a.PolicyId, actor, a.Objects) + commitment, err := commitment.GenerateCommitmentWithoutValidation(a.PolicyId, actor, a.Objects) require.NoError(ctx.T, err) cmd := types.NewCommitRegistrationCmd(commitment) result, err := dispatchPolicyCmd(ctx, a.PolicyId, a.Actor, cmd) @@ -260,7 +255,7 @@ type RevealRegistrationAction struct { func (a *RevealRegistrationAction) Run(ctx *TestCtx) *types.RevealRegistrationCmdResult { actor := coretypes.NewActor(a.Actor.DID) - proof, err := registration.ProofForObject(a.PolicyId, actor, a.Index, a.Objects) + proof, err := commitment.ProofForObject(a.PolicyId, actor, a.Index, a.Objects) require.NoError(ctx.T, err) cmd := types.NewRevealRegistrationCmd(a.CommitmentId, proof) result, err := dispatchPolicyCmd(ctx, a.PolicyId, a.Actor, cmd) diff --git a/tests/integration/acp/ctx.go b/tests/integration/acp/ctx.go index 0f196787..de36ec9b 100644 --- a/tests/integration/acp/ctx.go +++ b/tests/integration/acp/ctx.go @@ -6,11 +6,13 @@ import ( "testing" "time" + prototypes "github.com/cosmos/gogoproto/types" "github.com/stretchr/testify/require" "github.com/sourcenetwork/sourcehub/x/acp/signed_policy_cmd" "github.com/sourcenetwork/sourcehub/x/acp/testutil" "github.com/sourcenetwork/sourcehub/x/acp/types" + "github.com/sourcenetwork/sourcehub/x/acp/utils" ) var DefaultTs = MustDateTimeToProto("2024-01-01 00:00:00") @@ -29,21 +31,32 @@ func NewTestCtxFromConfig(t *testing.T, config TestConfig) *TestCtx { } executor := NewExecutor(t, config.ExecutorStrategy, params) + logicalClk := &logicalClockImpl{} + height, err := logicalClk.GetTimestampNow(context.TODO()) + require.NoError(t, err) + + tx := GenRandomTx(t) root := MustNewSourceHubActorFromName("root") ctx := &TestCtx{ - Ctx: context.TODO(), - T: t, - TxSigner: root, - Timestamp: time.Now(), - TokenIssueTs: time.Now(), + Ctx: context.TODO(), + T: t, + TxSigner: root, + TokenIssueTs: time.Now(), + TokenIssueProtoTs: prototypes.TimestampNow(), + ExecutionTs: &types.Timestamp{ + ProtoTs: prototypes.TimestampNow(), + BlockHeight: height, + }, Executor: executor, Strategy: config.AuthStrategy, ActorType: config.ActorType, - LogicalClock: &logicalClockImpl{}, + LogicalClock: logicalClk, Params: params, + Tx: tx, + TxHash: utils.HashTx(tx), } - _, err := executor.GetOrCreateAccountFromActor(ctx, root) + _, err = executor.GetOrCreateAccountFromActor(ctx, root) require.NoError(t, err) return ctx @@ -54,17 +67,18 @@ type TestCtx struct { T *testing.T State TestState // Signer for Txs while running tests under Bearer or Signed Auth modes - TxSigner *TestActor - // Timestamp used to generate Msgs in Test - Timestamp time.Time - TokenIssueTs time.Time - Executor MsgExecutor - Strategy AuthenticationStrategy - AccountKeeper *testutil.AccountKeeperStub - ActorType ActorKeyType - LogicalClock signed_policy_cmd.LogicalClock - TxHash string - Params types.Params + TxSigner *TestActor + ExecutionTs *types.Timestamp + TokenIssueTs time.Time + TokenIssueProtoTs *prototypes.Timestamp + Executor MsgExecutor + Strategy AuthenticationStrategy + AccountKeeper *testutil.AccountKeeperStub + ActorType ActorKeyType + LogicalClock signed_policy_cmd.LogicalClock + Tx []byte + TxHash []byte + Params types.Params } func NewTestCtx(t *testing.T) *TestCtx { @@ -100,6 +114,24 @@ func (c *TestCtx) GetSourceHubAccount(alias string) *TestActor { return acc } +func (c *TestCtx) GetRecordMetadataForActor(actor string) *types.RecordMetadata { + return &types.RecordMetadata{ + CreationTs: c.ExecutionTs, + TxHash: c.TxHash, + TxSigner: c.TxSigner.SourceHubAddr, + OwnerDid: c.GetActor(actor).DID, + } +} + +func (c *TestCtx) GetRootRecordMetadata() *types.RecordMetadata { + return &types.RecordMetadata{ + CreationTs: c.ExecutionTs, + TxHash: c.TxHash, + TxSigner: c.TxSigner.SourceHubAddr, + OwnerDid: c.TxSigner.DID, + } +} + func (c *TestCtx) GetParams() types.Params { return types.NewParams() } diff --git a/tests/integration/acp/dispatchers.go b/tests/integration/acp/dispatchers.go index 5593fc07..bd77c6da 100644 --- a/tests/integration/acp/dispatchers.go +++ b/tests/integration/acp/dispatchers.go @@ -13,11 +13,10 @@ func dispatchPolicyCmd(ctx *TestCtx, policyId string, actor *TestActor, policyCm case BearerToken: jws := genToken(ctx, actor) msg := &types.MsgBearerPolicyCmd{ - Creator: ctx.TxSigner.SourceHubAddr, - BearerToken: jws, - PolicyId: policyId, - Cmd: policyCmd, - CreationTime: TimeToProto(ctx.Timestamp), + Creator: ctx.TxSigner.SourceHubAddr, + BearerToken: jws, + PolicyId: policyId, + Cmd: policyCmd, } resp, respErr := ctx.Executor.BearerPolicyCmd(ctx, msg) if resp != nil { @@ -29,7 +28,7 @@ func dispatchPolicyCmd(ctx *TestCtx, policyId string, actor *TestActor, policyCm builder := signed_policy_cmd.NewCmdBuilder(ctx.LogicalClock, ctx.GetParams()) builder.PolicyCmd(policyCmd) builder.Actor(actor.DID) - builder.CreationTimestamp(TimeToProto(ctx.Timestamp)) + builder.IssuedAt(ctx.TokenIssueProtoTs) builder.PolicyID(policyId) builder.SetSigner(actor.Signer) jws, err = builder.BuildJWS(ctx) @@ -49,10 +48,9 @@ func dispatchPolicyCmd(ctx *TestCtx, policyId string, actor *TestActor, policyCm // For Direct Authentication we use the action Action as the signer ctx.TxSigner = actor msg := &types.MsgDirectPolicyCmd{ - Creator: actor.SourceHubAddr, - PolicyId: policyId, - Cmd: policyCmd, - CreationTime: TimeToProto(ctx.Timestamp), + Creator: actor.SourceHubAddr, + PolicyId: policyId, + Cmd: policyCmd, } resp, respErr := ctx.Executor.DirectPolicyCmd(ctx, msg) if resp != nil { diff --git a/tests/integration/acp/suite/object/register_test.go b/tests/integration/acp/suite/object/register_test.go index 0c14b36e..de8f6044 100644 --- a/tests/integration/acp/suite/object/register_test.go +++ b/tests/integration/acp/suite/object/register_test.go @@ -37,17 +37,11 @@ func TestRegisterObject_RegisteringNewObjectIsSucessful(t *testing.T) { Actor: ctx.GetActor("bob"), Object: coretypes.NewObject("resource", "foo"), Expected: &types.RegisterObjectCmdResult{ - Record: &coretypes.RelationshipRecord{ + Record: &types.RelationshipRecord{ PolicyId: ctx.State.PolicyId, Relationship: coretypes.NewActorRelationship("resource", "foo", "owner", bob.DID), Archived: false, - Metadata: &coretypes.RecordMetadata{ - Creator: &coretypes.Principal{ - Kind: coretypes.PrincipalKind_DID, - Identifier: bob.DID, - }, - CreationTs: test.TimeToProto(ctx.Timestamp), - }, + Metadata: ctx.GetRecordMetadataForActor("bob"), }, }, } diff --git a/tests/integration/acp/suite/object/reveal_registration_test.go b/tests/integration/acp/suite/object/reveal_registration_test.go index 3db725be..c6f9e718 100644 --- a/tests/integration/acp/suite/object/reveal_registration_test.go +++ b/tests/integration/acp/suite/object/reveal_registration_test.go @@ -132,7 +132,7 @@ func TestRevealRegistration_ObjectRegisteredAfterCommitment_RegistrationAmended( result := a.Run(ctx) require.Equal(ctx.T, result.Event.Type, types.ObjectRegistrationEventType_AMENDMENT) - require.Equal(ctx.T, result.Record.Metadata.Creator, ctx.GetActor("bob").DID) + require.Equal(ctx.T, result.Record.Metadata.OwnerDid, ctx.GetActor("bob").DID) require.Equal(ctx.T, result.Record.Relationship, coretypes.NewActorRelationship("file", "foo.txt", "owner", ctx.GetActor("bob").DID)) } @@ -192,7 +192,7 @@ func TestRevealRegistration_ObjectRegisteredThroughNewerCommitment_RegistrationI // Then Bob is the owner of foo.txt require.Equal(ctx.T, result.Event.Type, types.ObjectRegistrationEventType_AMENDMENT) - require.Equal(ctx.T, result.Record.Metadata.Creator, ctx.GetActor("bob").DID) + require.Equal(ctx.T, result.Record.Metadata.OwnerDid, ctx.GetActor("bob").DID) require.Equal(ctx.T, result.Record.Relationship, coretypes.NewActorRelationship("file", "foo.txt", "owner", ctx.GetActor("bob").DID)) } diff --git a/tests/integration/acp/suite/policy/query_test.go b/tests/integration/acp/suite/policy/query_test.go index 92055ec7..33ea682d 100644 --- a/tests/integration/acp/suite/policy/query_test.go +++ b/tests/integration/acp/suite/policy/query_test.go @@ -26,10 +26,11 @@ name: policy action := test.GetPolicyAction{ Id: pol.Id, - Expected: &acptypes.QueryPolicyResponse{ + Expected: &acptypes.PolicyRecord{ Policy: pol, MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, - PolicyRaw: policyStr, + RawPolicy: policyStr, + Metadata: ctx.GetRootRecordMetadata(), }, } action.Run(ctx) diff --git a/tests/integration/acp/suite/relationship/set_test.go b/tests/integration/acp/suite/relationship/set_test.go index 165f29b3..92b34322 100644 --- a/tests/integration/acp/suite/relationship/set_test.go +++ b/tests/integration/acp/suite/relationship/set_test.go @@ -55,14 +55,8 @@ func TestSetRelationship_OwnerCanShareObjectTheyOwn(t *testing.T) { Actor: ctx.GetActor("alice"), Expected: &types.SetRelationshipCmdResult{ RecordExisted: false, - Record: &coretypes.RelationshipRecord{ - Metadata: &coretypes.RecordMetadata{ - Creator: &coretypes.Principal{ - Kind: coretypes.PrincipalKind_DID, - Identifier: ctx.GetActor("alice").DID, - }, - CreationTs: test.TimeToProto(ctx.Timestamp), - }, + Record: &types.RelationshipRecord{ + Metadata: ctx.GetRecordMetadataForActor("bob"), PolicyId: ctx.State.PolicyId, Relationship: coretypes.NewActorRelationship("file", "foo", "reader", bob), Archived: false, @@ -121,14 +115,8 @@ func TestSetRelationship_ManagerActorCanDelegateAccessToAnotherActor(t *testing. Actor: ctx.GetActor("bob"), Expected: &types.SetRelationshipCmdResult{ RecordExisted: false, - Record: &coretypes.RelationshipRecord{ - Metadata: &coretypes.RecordMetadata{ - Creator: &coretypes.Principal{ - Kind: coretypes.PrincipalKind_DID, - Identifier: bob, - }, - CreationTs: test.TimeToProto(ctx.Timestamp), - }, + Record: &types.RelationshipRecord{ + Metadata: ctx.GetRecordMetadataForActor("bob"), PolicyId: ctx.State.PolicyId, Relationship: coretypes.NewActorRelationship("file", "foo", "reader", charlie), Archived: false, diff --git a/tests/integration/acp/utils.go b/tests/integration/acp/utils.go index d339340f..488d0739 100644 --- a/tests/integration/acp/utils.go +++ b/tests/integration/acp/utils.go @@ -1,8 +1,10 @@ package test import ( + "crypto/rand" "errors" "reflect" + "testing" "time" gogotypes "github.com/cosmos/gogoproto/types" @@ -33,28 +35,35 @@ func TimeToProto(ts time.Time) *gogotypes.Timestamp { Nanos: 0, } } - -func AssertResults(ctx *TestCtx, got, want any, gotErr, wantErr error) { - if wantErr != nil { - require.NotNil(ctx.T, gotErr, "expected an error but got none") - if errors.Is(gotErr, wantErr) { - assert.ErrorIs(ctx.T, gotErr, wantErr) +func AssertError(ctx *TestCtx, got, want error) { + if want != nil { + require.NotNil(ctx.T, got, "expected an error but got none") + if errors.Is(got, want) { + assert.ErrorIs(ctx.T, got, want) } else { // Errors returned from SDK operations (RPC communication to a SourceHub node) // no longer have the original errors wrapped, therefore we compare a string as fallback strat. - gotErrStr := gotErr.Error() - wantErrStr := wantErr.Error() + gotErrStr := got.Error() + wantErrStr := want.Error() assert.Contains(ctx.T, gotErrStr, wantErrStr) } } else { - assert.NoError(ctx.T, gotErr) + assert.NoError(ctx.T, got) } +} + +func AssertValue(ctx *TestCtx, got, want any) { if !isNil(want) { assert.Equal(ctx.T, want, got) } } +func AssertResults(ctx *TestCtx, got, want any, gotErr, wantErr error) { + AssertError(ctx, gotErr, wantErr) + AssertValue(ctx, got, want) +} + func isNil(object interface{}) bool { if object == nil { return true @@ -86,3 +95,10 @@ func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool { return false } + +func GenRandomTx(t *testing.T) []byte { + tx := make([]byte, 0, 100) + _, err := rand.Read(tx) + require.NoError(t, err) + return tx +} diff --git a/x/acp/access_decision/commands.go b/x/acp/access_decision/commands.go index e2de3a66..b68a7c4a 100644 --- a/x/acp/access_decision/commands.go +++ b/x/acp/access_decision/commands.go @@ -5,7 +5,6 @@ import ( "fmt" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - prototypes "github.com/cosmos/gogoproto/types" "github.com/sourcenetwork/acp_core/pkg/errors" coretypes "github.com/sourcenetwork/acp_core/pkg/types" @@ -21,7 +20,7 @@ type EvaluateAccessRequestsCommand struct { Operations []*types.Operation Actor string - CreationTime *prototypes.Timestamp + CreationTime *types.Timestamp // Creator is the same as the Tx signer Creator authtypes.AccountI diff --git a/x/acp/client/cli/tx_bearer_policy_cmd.go b/x/acp/client/cli/tx_bearer_policy_cmd.go index 6fa989f6..fecfc78b 100644 --- a/x/acp/client/cli/tx_bearer_policy_cmd.go +++ b/x/acp/client/cli/tx_bearer_policy_cmd.go @@ -24,7 +24,7 @@ func bearerDispatcher(cmd *cobra.Command, polId string, polCmd *types.PolicyCmd) token := flag.Value.String() creator := clientCtx.GetFromAddress().String() - msg := types.NewMsgBearerPolicyCmdNow(creator, token, polId, polCmd) + msg := types.NewMsgBearerPolicyCmd(creator, token, polId, polCmd) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) } diff --git a/x/acp/client/cli/tx_check_access.go b/x/acp/client/cli/tx_check_access.go index c51f9013..2c4048df 100644 --- a/x/acp/client/cli/tx_check_access.go +++ b/x/acp/client/cli/tx_check_access.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - gogotypes "github.com/cosmos/gogoproto/types" coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/spf13/cobra" @@ -51,7 +50,6 @@ func CmdCheckAccess() *cobra.Command { msg := &types.MsgCheckAccess{ Creator: clientCtx.GetFromAddress().String(), PolicyId: policyId, - CreationTime: gogotypes.TimestampNow(), AccessRequest: accessRequest, } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) diff --git a/x/acp/client/cli/tx_create_policy.go b/x/acp/client/cli/tx_create_policy.go index 4f62371d..207b751c 100644 --- a/x/acp/client/cli/tx_create_policy.go +++ b/x/acp/client/cli/tx_create_policy.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - gogotypes "github.com/cosmos/gogoproto/types" coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/spf13/cobra" @@ -73,10 +72,9 @@ func CmdCreatePolicy() *cobra.Command { } msg := &types.MsgCreatePolicy{ - Creator: clientCtx.GetFromAddress().String(), - Policy: string(policy), - MarshalType: marshalingType, - CreationTime: gogotypes.TimestampNow(), + Creator: clientCtx.GetFromAddress().String(), + Policy: string(policy), + MarshalType: marshalingType, } if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/acp/client/cli/tx_direct_policy_cmd.go b/x/acp/client/cli/tx_direct_policy_cmd.go index 1eee74be..4b74825e 100644 --- a/x/acp/client/cli/tx_direct_policy_cmd.go +++ b/x/acp/client/cli/tx_direct_policy_cmd.go @@ -19,7 +19,7 @@ func directDispatcher(cmd *cobra.Command, polId string, polCmd *types.PolicyCmd) } creator := clientCtx.GetFromAddress().String() - msg := types.NewMsgDirectPolicyCmdNow(creator, polId, polCmd) + msg := types.NewMsgDirectPolicyCmd(creator, polId, polCmd) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) } diff --git a/x/acp/registration/commitment.go b/x/acp/commitment/commitment.go similarity index 99% rename from x/acp/registration/commitment.go rename to x/acp/commitment/commitment.go index 7c8bcd8c..7cb4627b 100644 --- a/x/acp/registration/commitment.go +++ b/x/acp/commitment/commitment.go @@ -1,4 +1,4 @@ -package registration +package commitment import ( "crypto/sha256" diff --git a/x/acp/registration/commitment_repository.go b/x/acp/commitment/commitment_repository.go similarity index 99% rename from x/acp/registration/commitment_repository.go rename to x/acp/commitment/commitment_repository.go index 961b9065..3ddaa106 100644 --- a/x/acp/registration/commitment_repository.go +++ b/x/acp/commitment/commitment_repository.go @@ -1,4 +1,4 @@ -package registration +package commitment import ( "context" diff --git a/x/acp/registration/commitment_test.go b/x/acp/commitment/commitment_test.go similarity index 98% rename from x/acp/registration/commitment_test.go rename to x/acp/commitment/commitment_test.go index 40525ee9..9f3fd987 100644 --- a/x/acp/registration/commitment_test.go +++ b/x/acp/commitment/commitment_test.go @@ -1,4 +1,4 @@ -package registration +package commitment import ( "testing" diff --git a/x/acp/commitment/constants.go b/x/acp/commitment/constants.go new file mode 100644 index 00000000..8bcdb73a --- /dev/null +++ b/x/acp/commitment/constants.go @@ -0,0 +1,4 @@ +package commitment + +// commitmentLen is a Sha256 Hash, meaning we expect 32 bytes +const commitmentLen int = 256 / 8 diff --git a/x/acp/commitment/errors.go b/x/acp/commitment/errors.go new file mode 100644 index 00000000..60f22e53 --- /dev/null +++ b/x/acp/commitment/errors.go @@ -0,0 +1,14 @@ +package commitment + +import ( + "fmt" + + "github.com/sourcenetwork/acp_core/pkg/errors" + "github.com/sourcenetwork/sourcehub/x/acp/types" +) + +func errInvalidCommitment(policy string, commitment []byte) error { + return types.New(fmt.Sprintf("invalid commitment: got %v: want %v", len(commitment), commitmentLen), + types.ErrorType_BAD_INPUT, + errors.Pair("policy", policy)) +} diff --git a/x/acp/commitment/service.go b/x/acp/commitment/service.go new file mode 100644 index 00000000..df6c6282 --- /dev/null +++ b/x/acp/commitment/service.go @@ -0,0 +1,170 @@ +package commitment + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sourcenetwork/acp_core/pkg/errors" + coretypes "github.com/sourcenetwork/acp_core/pkg/types" + "github.com/sourcenetwork/sourcehub/x/acp/types" +) + +func NewCommitmentService(engine coretypes.ACPEngineServer, repository CommitmentRepository) *CommitmentService { + return &CommitmentService{ + engine: engine, + repository: repository, + } +} + +// CommitmentService abstracts registration commitment operations +type CommitmentService struct { + engine coretypes.ACPEngineServer + repository CommitmentRepository +} + +// BuildCommitment produces a byte commitment for actor and objects. +// The commitment is guaranteed to be valid, as we verify that no object has been registered yet. +func (s *CommitmentService) BuildCommitment(ctx sdk.Context, policyId string, actor *coretypes.Actor, objects []*coretypes.Object) ([]byte, error) { + rec, err := s.engine.GetPolicy(ctx, &coretypes.GetPolicyRequest{ + Id: policyId, + }) + if err != nil { + return nil, err + } + if rec == nil { + return nil, errors.ErrPolicyNotFound(policyId) + } + + for _, obj := range objects { + status, err := s.engine.GetObjectRegistration(ctx, &coretypes.GetObjectRegistrationRequest{ + PolicyId: policyId, + Object: obj, + }) + if err != nil { + return nil, err + } + if status.IsRegistered { + return nil, errors.Wrap("object already registered", errors.ErrorType_BAD_INPUT, + errors.Pair("policy", policyId), + errors.Pair("resource", obj.Resource), + errors.Pair("object", obj.Id), + ) + } + } + + return GenerateCommitmentWithoutValidation(policyId, actor, objects) +} + +// FlagExpiredCommitments iterates over stored commitments, +// filters for expired commitments wrt the current block time, +// flags them as expired and returns the newly expired commitments +func (s *CommitmentService) FlagExpiredCommitments(ctx sdk.Context) ([]*types.RegistrationsCommitment, error) { + now, err := types.TimestampFromCtx(ctx) + if err != nil { + return nil, err + } + iter, err := s.repository.GetNonExpiredCommitments(ctx) + if err != nil { + return nil, err + } + defer iter.Close() + + var processed []*types.RegistrationsCommitment + for !iter.Finished() { + commitment, err := iter.Value() + if err != nil { + return nil, err + } + expired, err := commitment.IsExpiredAgainst(now) + if err != nil { + return nil, err + } + if expired { + commitment.Expired = true + processed = append(processed, commitment) + } + + err = iter.Next(ctx) + if err != nil { + return nil, err + } + } + + for _, commitment := range processed { + err := s.repository.Set(ctx, commitment) + if err != nil { + return nil, errors.Wrap("expiring commitment", err, errors.Pair("commitment", commitment.Id)) + } + } + + return processed, nil +} + +// SetNewCommitment sets a new RegistrationCommitment +func (s *CommitmentService) SetNewCommitment(ctx sdk.Context, policyId string, commitment []byte, actor *coretypes.Actor, params *types.Params, msgCreator string) (*types.RegistrationsCommitment, error) { + rec, err := s.engine.GetPolicy(ctx, &coretypes.GetPolicyRequest{ + Id: policyId, + }) + if err != nil { + return nil, err + } + if rec == nil { + return nil, errors.ErrPolicyNotFound(policyId) + } + + if len(commitment) != commitmentLen { + return nil, errInvalidCommitment(policyId, commitment) + } + + metadata, err := types.BuildRecordMetadata(ctx, actor.Id, msgCreator) + if err != nil { + return nil, err + } + + registration := &types.RegistrationsCommitment{ + Id: 0, // doesn't matter since it will be auto-generated + PolicyId: policyId, + Commitment: commitment, + Expired: false, + Validity: params.RegistrationsCommitmentValidity, + Metadata: metadata, + } + + err = s.repository.Create(ctx, registration) + if err != nil { + return nil, err + } + return registration, nil +} + +// ValidateOpening verifies whether the given opening proof is valid for the authenticated actor and +// the objects +// returns true if opening is valid +func (s *CommitmentService) ValidateOpening(ctx sdk.Context, commitmentId uint64, proof *types.RegistrationProof, actor *coretypes.Actor) (bool, error) { + opt, err := s.repository.GetById(ctx, commitmentId) + if err != nil { + return false, err + } + if opt.Empty() { + return false, errors.Wrap("RegistrationsCommimtnet", errors.ErrorType_NOT_FOUND, + errors.Pair("id", commitmentId)) + } + + commitment := opt.GetValue() + now, err := types.TimestampFromCtx(ctx) + if err != nil { + return false, errors.NewFromBaseError(err, errors.ErrorType_INTERNAL, "failed determining current timestamp") + } + after, err := types.IsAfter(commitment.Metadata.CreationTs, commitment.Validity, now) + if err != nil { + return false, errors.NewFromBaseError(err, errors.ErrorType_INTERNAL, "invalid timestmap format") + } + if after { + return false, errors.Wrap("commitment expired", errors.ErrorType_OPERATION_FORBIDDEN, + errors.Pair("commitment", commitmentId)) + } + + ok, err := VerifyProof(commitment.Commitment, commitment.PolicyId, actor, proof) + if err != nil { + return false, errors.Wrap("invalid registration opening", err) + } + return ok, nil +} diff --git a/x/acp/commitment/types.go b/x/acp/commitment/types.go new file mode 100644 index 00000000..426a5baf --- /dev/null +++ b/x/acp/commitment/types.go @@ -0,0 +1,24 @@ +package commitment + +import ( + "context" + + "github.com/sourcenetwork/raccoondb/v2/iterator" + rctypes "github.com/sourcenetwork/raccoondb/v2/types" + "github.com/sourcenetwork/sourcehub/x/acp/types" +) + +type CommitmentRepository interface { + // Create sets a new RegistrationCommitment using the next free up id. + // Sets reg.Id with the effective record Id used. + Create(ctx context.Context, reg *types.RegistrationsCommitment) error + + Set(ctx context.Context, reg *types.RegistrationsCommitment) error + + GetById(ctx context.Context, id uint64) (rctypes.Option[*types.RegistrationsCommitment], error) + + FilterByCommitment(ctx context.Context, commitment []byte) (iterator.Iterator[*types.RegistrationsCommitment], error) + + // GetNonExpiredCommitments returns all commitments whose expiration flag is false + GetNonExpiredCommitments(ctx context.Context) (iterator.Iterator[*types.RegistrationsCommitment], error) +} diff --git a/x/acp/keeper/abci.go b/x/acp/keeper/abci.go index 09ba81c7..12fd25e1 100644 --- a/x/acp/keeper/abci.go +++ b/x/acp/keeper/abci.go @@ -5,22 +5,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sourcenetwork/acp_core/pkg/errors" - "github.com/sourcenetwork/sourcehub/x/acp/registration" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/types" ) func (k *Keeper) EndBlocker(goCtx context.Context) ([]*types.RegistrationsCommitment, error) { - return nil, nil ctx := sdk.UnwrapSDKContext(goCtx) - - objRepo := k.GetObjectEventRepository(ctx) - evService := registration.NewEventService(objRepo) - commitRepo := k.GetRegistrationsCommitmentRepository(ctx) engine, err := k.GetACPEngine(ctx) if err != nil { return nil, err } - service := registration.NewRegistrationService(engine, evService, commitRepo) + repo := k.GetRegistrationsCommitmentRepository(ctx) + service := commitment.NewCommitmentService(engine, repo) commitments, err := service.FlagExpiredCommitments(ctx) if err != nil { diff --git a/x/acp/keeper/abci_test.go b/x/acp/keeper/abci_test.go index 5947339d..35743d5b 100644 --- a/x/acp/keeper/abci_test.go +++ b/x/acp/keeper/abci_test.go @@ -6,7 +6,6 @@ import ( prototypes "github.com/cosmos/gogoproto/types" "github.com/stretchr/testify/require" - coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -16,12 +15,22 @@ func TestEndBlocker(t *testing.T) { repo := k.GetRegistrationsCommitmentRepository(ctx) err := repo.Set(ctx, &types.RegistrationsCommitment{ - Id: 1, - PolicyId: "abc", - Actor: coretypes.NewActor("abc"), + Id: 1, + PolicyId: "abc", + Metadata: &types.RecordMetadata{ + OwnerDid: "abc", + TxHash: []byte("00"), + TxSigner: "source1235", + CreationTs: &types.Timestamp{ + ProtoTs: &prototypes.Timestamp{ + Seconds: 0, + Nanos: 0, + }, + BlockHeight: 1, + }, + }, Commitment: []byte("0"), Expired: false, - TxHash: []byte("00"), Validity: &types.Duration{ Duration: &types.Duration_ProtoDuration{ ProtoDuration: &prototypes.Duration{ @@ -29,13 +38,6 @@ func TestEndBlocker(t *testing.T) { }, }, }, - CreationTs: &types.Timestamp{ - ProtoTs: &prototypes.Timestamp{ - Seconds: 0, - Nanos: 0, - }, - BlockHeight: 1, - }, }) require.NoError(t, err) diff --git a/x/acp/keeper/keeper.go b/x/acp/keeper/keeper.go index 91e0c773..21f9f70f 100644 --- a/x/acp/keeper/keeper.go +++ b/x/acp/keeper/keeper.go @@ -12,10 +12,10 @@ import ( acpruntime "github.com/sourcenetwork/acp_core/pkg/runtime" "github.com/sourcenetwork/acp_core/pkg/services" - coretypes "github.com/sourcenetwork/acp_core/pkg/types" "github.com/sourcenetwork/raccoondb/v2/primitives" "github.com/sourcenetwork/sourcehub/x/acp/access_decision" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/registration" "github.com/sourcenetwork/sourcehub/x/acp/stores" "github.com/sourcenetwork/sourcehub/x/acp/types" @@ -74,7 +74,7 @@ func (k *Keeper) GetAccessDecisionRepository(ctx sdk.Context) access_decision.Re return access_decision.NewAccessDecisionRepository(adapted) } -func (k *Keeper) GetACPEngine(ctx sdk.Context) (coretypes.ACPEngineServer, error) { +func (k *Keeper) GetACPEngine(ctx sdk.Context) (*services.EngineService, error) { kv := k.storeService.OpenKVStore(ctx) adapted := runtime.KVStoreAdapter(kv) raccoonAdapted := stores.RaccoonKVFromCosmos(adapted) @@ -85,15 +85,14 @@ func (k *Keeper) GetACPEngine(ctx sdk.Context) (coretypes.ACPEngineServer, error if err != nil { return nil, err } - return services.NewACPEngine(runtime), nil } -func (k *Keeper) GetRegistrationsCommitmentRepository(ctx sdk.Context) registration.CommitmentRepository { +func (k *Keeper) GetRegistrationsCommitmentRepository(ctx sdk.Context) commitment.CommitmentRepository { cmtkv := k.storeService.OpenKVStore(ctx) kv := stores.NewRaccoonKV(cmtkv) kv = primitives.NewPrefixedKV(kv, []byte(types.RegistrationsCommitmentPrefix)) - repo, err := registration.NewKVRegistrationRepository(kv) + repo, err := commitment.NewKVRegistrationRepository(kv) if err != nil { panic(err) } diff --git a/x/acp/keeper/msg_server_bearer_policy_cmd.go b/x/acp/keeper/msg_server_bearer_policy_cmd.go index b01f49ec..3b9d7184 100644 --- a/x/acp/keeper/msg_server_bearer_policy_cmd.go +++ b/x/acp/keeper/msg_server_bearer_policy_cmd.go @@ -8,6 +8,7 @@ import ( "github.com/sourcenetwork/sourcehub/x/acp/bearer_token" "github.com/sourcenetwork/sourcehub/x/acp/did" + "github.com/sourcenetwork/sourcehub/x/acp/policy_cmd" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -20,8 +21,13 @@ func (k msgServer) BearerPolicyCmd(goCtx context.Context, msg *types.MsgBearerPo return nil, err } - result, err := dispatchPolicyCmd(ctx, &k.Keeper, msg.PolicyId, actorID, msg.CreationTime, msg.Cmd) + cmdCtx, err := policy_cmd.NewPolicyCmdCtx(ctx, msg.PolicyId, actorID, msg.Creator, k.GetParams(ctx)) + if err != nil { + return nil, err + } + handler := policy_cmd.Handler{} + result, err := handler.Dispatch(&cmdCtx, msg.Cmd) if err != nil { return nil, fmt.Errorf("PolicyCmd failed: %w", err) } diff --git a/x/acp/keeper/msg_server_check_access.go b/x/acp/keeper/msg_server_check_access.go index cf079255..56579048 100644 --- a/x/acp/keeper/msg_server_check_access.go +++ b/x/acp/keeper/msg_server_check_access.go @@ -39,11 +39,16 @@ func (k msgServer) CheckAccess(goCtx context.Context, msg *types.MsgCheckAccess) return nil, types.NewAccNotFoundErr(msg.Creator) } + ts, err := types.TimestampFromCtx(ctx) + if err != nil { + return nil, err + } + cmd := access_decision.EvaluateAccessRequestsCommand{ Policy: record.Record.Policy, Operations: msg.AccessRequest.Operations, Actor: msg.AccessRequest.Actor.Id, - CreationTime: msg.CreationTime, + CreationTime: ts, Creator: creatorAcc, CurrentHeight: uint64(ctx.BlockHeight()), } diff --git a/x/acp/keeper/msg_server_create_policy.go b/x/acp/keeper/msg_server_create_policy.go index 34b29b6f..c98fabca 100644 --- a/x/acp/keeper/msg_server_create_policy.go +++ b/x/acp/keeper/msg_server_create_policy.go @@ -2,13 +2,14 @@ package keeper import ( "context" - "encoding/hex" "fmt" - comettypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sourcenetwork/acp_core/pkg/auth" + "github.com/sourcenetwork/acp_core/pkg/errors" coretypes "github.com/sourcenetwork/acp_core/pkg/types" + hubtypes "github.com/sourcenetwork/sourcehub/types" + "github.com/sourcenetwork/sourcehub/x/acp/did" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -26,29 +27,45 @@ func (k msgServer) CreatePolicy(goCtx context.Context, msg *types.MsgCreatePolic return nil, err } - principal := coretypes.RootPrincipal() - goCtx = auth.InjectPrincipal(goCtx, principal) + addr, err := hubtypes.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, fmt.Errorf("CreatePolicy: %v: %w", err, types.NewErrInvalidAccAddrErr(err, msg.Creator)) + } - tx := comettypes.Tx(ctx.TxBytes()) - txHash := hex.EncodeToString(tx.Hash()) + acc := k.accountKeeper.GetAccount(ctx, addr) + if acc == nil { + return nil, fmt.Errorf("CreatePolicy: %w", types.NewAccNotFoundErr(msg.Creator)) + } + actorID, err := did.IssueDID(acc) + if err != nil { + return nil, errors.Wrap("DirectPolicyCmd: could not issue did to creator", + errors.ErrorType_BAD_INPUT, errors.Pair("address", msg.Creator)) + } + + metadata, err := types.BuildACPSuppliedMetadata(ctx, actorID, msg.Creator) + if err != nil { + return nil, err + } + + principal := coretypes.RootPrincipal() + goCtx = auth.InjectPrincipal(goCtx, principal) coreResult, err := engine.CreatePolicy(goCtx, &coretypes.CreatePolicyRequest{ Policy: msg.Policy, MarshalType: msg.MarshalType, - Metadata: &coretypes.SuppliedMetadata{ - Attributes: map[string]string{ - txHashMapKey: txHash, - creatorMapKey: msg.Creator, - }, - }, + Metadata: metadata, }) if err != nil { return nil, fmt.Errorf("CreatePolicy: %w", err) } + rec, err := types.MapPolicy(coreResult.Record) + if err != nil { + return nil, fmt.Errorf("CreatePolicy: %w", err) + } // TODO event return &types.MsgCreatePolicyResponse{ - Policy: coreResult.Record.Policy, + Record: rec, }, nil } diff --git a/x/acp/keeper/msg_server_direct_policy_cmd.go b/x/acp/keeper/msg_server_direct_policy_cmd.go index 085aabf5..0e0d82ca 100644 --- a/x/acp/keeper/msg_server_direct_policy_cmd.go +++ b/x/acp/keeper/msg_server_direct_policy_cmd.go @@ -9,6 +9,7 @@ import ( hubtypes "github.com/sourcenetwork/sourcehub/types" "github.com/sourcenetwork/sourcehub/x/acp/did" + "github.com/sourcenetwork/sourcehub/x/acp/policy_cmd" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -31,7 +32,13 @@ func (k msgServer) DirectPolicyCmd(goCtx context.Context, msg *types.MsgDirectPo errors.ErrorType_BAD_INPUT, errors.Pair("address", msg.Creator)) } - result, err := dispatchPolicyCmd(ctx, &k.Keeper, msg.PolicyId, actorID, msg.CreationTime, msg.Cmd) + cmdCtx, err := policy_cmd.NewPolicyCmdCtx(ctx, msg.PolicyId, actorID, msg.Creator, k.GetParams(ctx)) + if err != nil { + return nil, err + } + + handler := policy_cmd.Handler{} + result, err := handler.Dispatch(&cmdCtx, msg.Cmd) if err != nil { return nil, err } diff --git a/x/acp/keeper/msg_server_signed_policy_cmd.go b/x/acp/keeper/msg_server_signed_policy_cmd.go index d0afcb09..55644948 100644 --- a/x/acp/keeper/msg_server_signed_policy_cmd.go +++ b/x/acp/keeper/msg_server_signed_policy_cmd.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sourcenetwork/sourcehub/x/acp/did" + "github.com/sourcenetwork/sourcehub/x/acp/policy_cmd" "github.com/sourcenetwork/sourcehub/x/acp/signed_policy_cmd" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -22,8 +23,13 @@ func (k msgServer) SignedPolicyCmd(goCtx context.Context, msg *types.MsgSignedPo return nil, fmt.Errorf("PolicyCmd: %w", err) } - result, err := dispatchPolicyCmd(ctx, &k.Keeper, payload.PolicyId, payload.Actor, payload.CreationTime, payload.Cmd) + cmdCtx, err := policy_cmd.NewPolicyCmdCtx(ctx, payload.PolicyId, payload.Actor, msg.Creator, k.GetParams(ctx)) + if err != nil { + return nil, err + } + handler := policy_cmd.Handler{} + result, err := handler.Dispatch(&cmdCtx, payload.Cmd) if err != nil { return nil, err } diff --git a/x/acp/keeper/policy_cmd.go b/x/acp/keeper/policy_cmd.go deleted file mode 100644 index 2e8ff005..00000000 --- a/x/acp/keeper/policy_cmd.go +++ /dev/null @@ -1,149 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - prototypes "github.com/cosmos/gogoproto/types" - "github.com/sourcenetwork/acp_core/pkg/auth" - "github.com/sourcenetwork/acp_core/pkg/errors" - coretypes "github.com/sourcenetwork/acp_core/pkg/types" - - "github.com/sourcenetwork/sourcehub/x/acp/registration" - "github.com/sourcenetwork/sourcehub/x/acp/types" -) - -func dispatchPolicyCmd(ctx sdk.Context, k *Keeper, policyId string, authenticatedActor string, ts *prototypes.Timestamp, cmd *types.PolicyCmd) (*types.PolicyCmdResult, error) { - engine, err := k.GetACPEngine(ctx) - if err != nil { - return nil, err - } - commitmentRepository := k.GetRegistrationsCommitmentRepository(ctx) - objectRepository := k.GetObjectEventRepository(ctx) - eventService := registration.NewEventService(objectRepository) - registrationService := registration.NewRegistrationService(engine, eventService, commitmentRepository) - - result := &types.PolicyCmdResult{} - - actor := coretypes.NewActor(authenticatedActor) - principal, err := coretypes.NewDIDPrincipal(authenticatedActor) - if err != nil { - return nil, err - } - goCtx := auth.InjectPrincipal(ctx, principal) - ctx = ctx.WithContext(goCtx) - - switch c := cmd.Cmd.(type) { - case *types.PolicyCmd_SetRelationshipCmd: - resp, respErr := engine.SetRelationship(goCtx, &coretypes.SetRelationshipRequest{ - PolicyId: policyId, - Relationship: c.SetRelationshipCmd.Relationship, - }) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_SetRelationshipResult{ - SetRelationshipResult: &types.SetRelationshipCmdResult{ - RecordExisted: resp.RecordExisted, - Record: resp.Record, - }, - } - case *types.PolicyCmd_DeleteRelationshipCmd: - resp, respErr := engine.DeleteRelationship(goCtx, &coretypes.DeleteRelationshipRequest{ - PolicyId: policyId, - Relationship: c.DeleteRelationshipCmd.Relationship, - }) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_DeleteRelationshipResult{ - DeleteRelationshipResult: &types.DeleteRelationshipCmdResult{ - RecordFound: resp.RecordFound, - }, - } - case *types.PolicyCmd_RegisterObjectCmd: - rec, _, respErr := registrationService.RegisterObject(ctx, policyId, c.RegisterObjectCmd.Object, actor) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_RegisterObjectResult{ - RegisterObjectResult: &types.RegisterObjectCmdResult{ - Record: rec, - }, - } - case *types.PolicyCmd_ArchiveObjectCmd: - resp, respErr := engine.ArchiveObject(goCtx, &coretypes.ArchiveObjectRequest{ - PolicyId: policyId, - Object: c.ArchiveObjectCmd.Object, - }) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_ArchiveObjectResult{ - ArchiveObjectResult: &types.ArchiveObjectCmdResult{ - Found: true, - RelationshipsRemoved: resp.RelationshipsRemoved, - }, - } - case *types.PolicyCmd_CommitRegistrationsCmd: - regCmd := c.CommitRegistrationsCmd - params := k.GetParams(ctx) - commitment, respErr := registrationService.CommitRegistration(ctx, policyId, regCmd.Commitment, actor, ¶ms) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_CommitRegistrationsResult{ - CommitRegistrationsResult: &types.CommitRegistrationsCmdResult{ - RegistrationsCommitment: commitment, - }, - } - case *types.PolicyCmd_FlagHijackAttemptCmd: - event, respErr := eventService.FlagHijackEvent(ctx, c.FlagHijackAttemptCmd.EventId, actor) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_FlagHijackAttemptResult{ - FlagHijackAttemptResult: &types.FlagHijackAttemptCmdResult{ - Event: event, - }, - } - case *types.PolicyCmd_RevealRegistrationCmd: - regCmd := c.RevealRegistrationCmd - rec, ev, respErr := registrationService.RevealRegistration(ctx, regCmd.RegistrationsCommitmentId, regCmd.Proof, actor) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_RevealRegistrationResult{ - RevealRegistrationResult: &types.RevealRegistrationCmdResult{ - Record: rec, - Event: ev, - Result: types.RegistrationResultStatus_UNARCHIVED, // TODO - }, - } - case *types.PolicyCmd_UnarchiveObjectCmd: - unarchCmd := c.UnarchiveObjectCmd - rec, _, respErr := registrationService.UnarchiveObject(ctx, policyId, unarchCmd.Object, actor) - if respErr != nil { - err = respErr - break - } - result.Result = &types.PolicyCmdResult_UnarchiveObjectResult{ - UnarchiveObjectResult: &types.UnarchiveObjectCmdResult{ - Record: rec, - RelationshipModified: true, // TODO - }, - } - - default: - err = errors.Wrap("unsuported command", errors.ErrUnknownVariant, errors.Pair("command", c)) - } - if err != nil { - return nil, err - } - return result, nil -} diff --git a/x/acp/keeper/query_filter_relationships.go b/x/acp/keeper/query_filter_relationships.go index 02204dc5..cb0b5343 100644 --- a/x/acp/keeper/query_filter_relationships.go +++ b/x/acp/keeper/query_filter_relationships.go @@ -8,6 +8,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/sourcenetwork/sourcehub/utils" "github.com/sourcenetwork/sourcehub/x/acp/types" ) @@ -30,7 +31,12 @@ func (k Keeper) FilterRelationships(goCtx context.Context, req *types.QueryFilte return nil, err } + mappedRecs, err := utils.MapFailableSlice(records.Records, types.MapRelationshipRecord) + if err != nil { + return nil, err + } + return &types.QueryFilterRelationshipsResponse{ - Records: records.Records, + Records: mappedRecs, }, nil } diff --git a/x/acp/keeper/query_generate_commitment.go b/x/acp/keeper/query_generate_commitment.go index b9166bd3..630d91b9 100644 --- a/x/acp/keeper/query_generate_commitment.go +++ b/x/acp/keeper/query_generate_commitment.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/gogoproto/jsonpb" "github.com/sourcenetwork/sourcehub/utils" - "github.com/sourcenetwork/sourcehub/x/acp/registration" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -26,19 +26,17 @@ func (k Keeper) GenerateCommitment(goCtx context.Context, req *types.QueryGenera return nil, err } - eventRepo := k.GetObjectEventRepository(ctx) commitRepo := k.GetRegistrationsCommitmentRepository(ctx) - eventService := registration.NewEventService(eventRepo) - service := registration.NewRegistrationService(engine, eventService, commitRepo) + commitmentService := commitment.NewCommitmentService(engine, commitRepo) - commitment, err := service.GenerateCommitment(ctx, req.PolicyId, req.Actor, req.Objects) + comm, err := commitmentService.BuildCommitment(ctx, req.PolicyId, req.Actor, req.Objects) if err != nil { return nil, err } proofs := make([]*types.RegistrationProof, 0, len(req.Objects)) for i := range req.Objects { - proof, err := registration.ProofForObject(req.PolicyId, req.Actor, i, req.Objects) + proof, err := commitment.ProofForObject(req.PolicyId, req.Actor, i, req.Objects) if err != nil { return nil, fmt.Errorf("generating proof for obj %v: %v", i, err) } @@ -53,8 +51,8 @@ func (k Keeper) GenerateCommitment(goCtx context.Context, req *types.QueryGenera } return &types.QueryGenerateCommitmentResponse{ - Commitment: commitment, - HexCommitment: hex.EncodeToString(commitment), + Commitment: comm, + HexCommitment: hex.EncodeToString(comm), Proofs: proofs, ProofsJson: proofsJson, }, nil diff --git a/x/acp/keeper/query_object_owner_test.go b/x/acp/keeper/query_object_owner_test.go index a1f1fdfe..77bf3265 100644 --- a/x/acp/keeper/query_object_owner_test.go +++ b/x/acp/keeper/query_object_owner_test.go @@ -56,10 +56,9 @@ actor: creator := accKeep.FirstAcc().GetAddress().String() msg := types.MsgCreatePolicy{ - Creator: creator, - Policy: policyStr, - MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, - CreationTime: timestamp, + Creator: creator, + Policy: policyStr, + MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, } msgServer := NewMsgServerImpl(keeper) @@ -68,14 +67,13 @@ actor: require.Nil(t, err) _, err = msgServer.DirectPolicyCmd(ctx, &types.MsgDirectPolicyCmd{ - Creator: creator, - PolicyId: resp.Policy.Id, - Cmd: types.NewRegisterObjectCmd(s.obj), - CreationTime: timestamp, + Creator: creator, + PolicyId: resp.Record.Policy.Id, + Cmd: types.NewRegisterObjectCmd(s.obj), }) require.Nil(t, err) - return ctx, keeper, accKeep.FirstAcc(), creator, resp.Policy.Id + return ctx, keeper, accKeep.FirstAcc(), creator, resp.Record.Policy.Id } func (s *queryObjectOwnerSuite) TestQueryReturnsObjectOwner() { diff --git a/x/acp/keeper/query_policy.go b/x/acp/keeper/query_policy.go index 295b7533..875baac8 100644 --- a/x/acp/keeper/query_policy.go +++ b/x/acp/keeper/query_policy.go @@ -33,9 +33,17 @@ func (k Keeper) Policy(goCtx context.Context, req *types.QueryPolicyRequest) (*t return nil, errors.ErrPolicyNotFound(req.Id) } + md, err := types.UmarshalRecordMetadata(rec.Record.Metadata) + if err != nil { + return nil, err + } + return &types.QueryPolicyResponse{ - Policy: rec.Record.Policy, - PolicyRaw: rec.Record.PolicyDefinition, - MarshalType: rec.Record.MarshalType, + Record: &types.PolicyRecord{ + Policy: rec.Record.Policy, + RawPolicy: rec.Record.PolicyDefinition, + MarshalType: rec.Record.MarshalType, + Metadata: md, + }, }, nil } diff --git a/x/acp/keeper/query_verify_access_request_test.go b/x/acp/keeper/query_verify_access_request_test.go index 60e815f7..7f7986c0 100644 --- a/x/acp/keeper/query_verify_access_request_test.go +++ b/x/acp/keeper/query_verify_access_request_test.go @@ -38,24 +38,22 @@ resources: ` msg := types.MsgCreatePolicy{ - Creator: creator, - Policy: policyStr, - MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, - CreationTime: timestamp, + Creator: creator, + Policy: policyStr, + MarshalType: coretypes.PolicyMarshalingType_SHORT_YAML, } resp, err := msgServer.CreatePolicy(ctx, &msg) require.Nil(t, err) _, err = msgServer.DirectPolicyCmd(ctx, &types.MsgDirectPolicyCmd{ - Creator: creator, - PolicyId: resp.Policy.Id, - Cmd: types.NewRegisterObjectCmd(obj), - CreationTime: timestamp, + Creator: creator, + PolicyId: resp.Record.Policy.Id, + Cmd: types.NewRegisterObjectCmd(obj), }) require.Nil(t, err) - return ctx, keeper, resp.Policy, creatorDID + return ctx, keeper, resp.Record.Policy, creatorDID } func TestVerifyAccessRequest_QueryingObjectsTheActorHasAccessToReturnsTrue(t *testing.T) { diff --git a/x/acp/policy_cmd/handler.go b/x/acp/policy_cmd/handler.go index 28e3b0f8..8e5f3814 100644 --- a/x/acp/policy_cmd/handler.go +++ b/x/acp/policy_cmd/handler.go @@ -3,36 +3,31 @@ package policy_cmd import ( "fmt" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/registration" "github.com/sourcenetwork/sourcehub/x/acp/types" - "github.com/sourcenetwork/sourcehub/x/acp/utils" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sourcenetwork/acp_core/pkg/auth" "github.com/sourcenetwork/acp_core/pkg/errors" coretypes "github.com/sourcenetwork/acp_core/pkg/types" ) -func NewRecordMetadata(ctx sdk.Context, txSigner string, actor string) (*types.RecordMetadata, error) { - ts, err := types.TimestampFromCtx(ctx) - if err != nil { - return nil, err - } - return &types.RecordMetadata{ - CreationTs: ts, - TxHash: utils.HashTx(ctx.TxBytes()), - TxSigner: txSigner, - OwnerDid: actor, - }, nil -} - type Handler struct { engine coretypes.ACPEngineServer eventService registration.EventService registrationService registration.RegistrationService - commitmentService registration.CommitmentService + commitmentService commitment.CommitmentService } func (h *Handler) Dispatch(ctx *PolicyCmdCtx, cmd *types.PolicyCmd) (*types.PolicyCmdResult, error) { + principal, err := coretypes.NewDIDPrincipal(ctx.PrincipalDID) + if err != nil { + return nil, err + } + goCtx := ctx.Ctx.Context() + goCtx = auth.InjectPrincipal(goCtx, principal) + ctx.Ctx = ctx.Ctx.WithContext(goCtx) + switch c := cmd.Cmd.(type) { case *types.PolicyCmd_SetRelationshipCmd: return h.SetRelationship(ctx, c.SetRelationshipCmd) @@ -56,7 +51,7 @@ func (h *Handler) Dispatch(ctx *PolicyCmdCtx, cmd *types.PolicyCmd) (*types.Poli } func (h *Handler) SetRelationship(ctx *PolicyCmdCtx, cmd *types.SetRelationshipCmd) (*types.PolicyCmdResult, error) { - metadata, err := NewRecordMetadata(ctx.SDKCtx, ctx.Signer, ctx.PrincipalDID) + metadata, err := types.BuildRecordMetadata(ctx.Ctx, ctx.PrincipalDID, ctx.Signer) if err != nil { return nil, err } @@ -65,7 +60,7 @@ func (h *Handler) SetRelationship(ctx *PolicyCmdCtx, cmd *types.SetRelationshipC return nil, fmt.Errorf("marshaling metadata: %w", err) } - resp, err := h.engine.SetRelationship(ctx.EngineContext, &coretypes.SetRelationshipRequest{ + resp, err := h.engine.SetRelationship(ctx.Ctx, &coretypes.SetRelationshipRequest{ PolicyId: ctx.PolicyId, Relationship: cmd.Relationship, Metadata: &coretypes.SuppliedMetadata{ @@ -76,7 +71,7 @@ func (h *Handler) SetRelationship(ctx *PolicyCmdCtx, cmd *types.SetRelationshipC return nil, err } - rec, err := MapRelationshipRecord(resp.Record) + rec, err := types.MapRelationshipRecord(resp.Record) if err != nil { return nil, fmt.Errorf("mapping relationship record: %w", err) @@ -93,7 +88,7 @@ func (h *Handler) SetRelationship(ctx *PolicyCmdCtx, cmd *types.SetRelationshipC } func (h *Handler) DeleteRelationship(ctx *PolicyCmdCtx, cmd *types.DeleteRelationshipCmd) (*types.PolicyCmdResult, error) { - resp, err := h.engine.DeleteRelationship(ctx.EngineContext, &coretypes.DeleteRelationshipRequest{ + resp, err := h.engine.DeleteRelationship(ctx.Ctx, &coretypes.DeleteRelationshipRequest{ PolicyId: ctx.PolicyId, Relationship: cmd.Relationship, }) @@ -111,12 +106,12 @@ func (h *Handler) DeleteRelationship(ctx *PolicyCmdCtx, cmd *types.DeleteRelatio func (h *Handler) RegisterObject(ctx *PolicyCmdCtx, cmd *types.RegisterObjectCmd) (*types.PolicyCmdResult, error) { actor := coretypes.NewActor(ctx.PrincipalDID) - rec, _, err := h.registrationService.RegisterObject(ctx.SDKCtx, ctx.PolicyId, cmd.Object, actor, ctx.Signer) + rec, _, err := h.registrationService.RegisterObject(ctx.Ctx, ctx.PolicyId, cmd.Object, actor, ctx.Signer) if err != nil { return nil, err } - r, err := MapRelationshipRecord(rec) + r, err := types.MapRelationshipRecord(rec) if err != nil { return nil, err } @@ -131,7 +126,7 @@ func (h *Handler) RegisterObject(ctx *PolicyCmdCtx, cmd *types.RegisterObjectCmd } func (h *Handler) ArchiveObject(ctx *PolicyCmdCtx, cmd *types.ArchiveObjectCmd) (*types.PolicyCmdResult, error) { - resp, err := h.engine.ArchiveObject(ctx.EngineContext, &coretypes.ArchiveObjectRequest{ + resp, err := h.engine.ArchiveObject(ctx.Ctx, &coretypes.ArchiveObjectRequest{ PolicyId: ctx.PolicyId, Object: cmd.Object, }) @@ -151,10 +146,11 @@ func (h *Handler) ArchiveObject(ctx *PolicyCmdCtx, cmd *types.ArchiveObjectCmd) func (h *Handler) CommitRegistrations(ctx *PolicyCmdCtx, cmd *types.CommitRegistrationsCmd) (*types.PolicyCmdResult, error) { actor := coretypes.NewActor(ctx.PrincipalDID) - commitment, err := h.commitmentService.SetNewCommitment(ctx.SDKCtx, ctx.PolicyId, cmd.Commitment, actor, &ctx.Params, ctx.Signer) + commitment, err := h.commitmentService.SetNewCommitment(ctx.Ctx, ctx.PolicyId, cmd.Commitment, actor, &ctx.Params, ctx.Signer) if err != nil { return nil, err } + return &types.PolicyCmdResult{ Result: &types.PolicyCmdResult_CommitRegistrationsResult{ CommitRegistrationsResult: &types.CommitRegistrationsCmdResult{ @@ -166,11 +162,12 @@ func (h *Handler) CommitRegistrations(ctx *PolicyCmdCtx, cmd *types.CommitRegist func (h *Handler) RevealRegistration(ctx *PolicyCmdCtx, cmd *types.RevealRegistrationCmd) (*types.PolicyCmdResult, error) { actor := coretypes.NewActor(ctx.PrincipalDID) - rec, ev, err := h.registrationService.RevealRegistration(ctx.SDKCtx, cmd.RegistrationsCommitmentId, cmd.Proof, actor, ctx.Signer) + + rec, ev, err := h.registrationService.RevealRegistration(ctx.Ctx, cmd.RegistrationsCommitmentId, cmd.Proof, actor, ctx.Signer) if err != nil { return nil, err } - r, err := MapRelationshipRecord(rec) + r, err := types.MapRelationshipRecord(rec) if err != nil { return nil, err } @@ -180,7 +177,6 @@ func (h *Handler) RevealRegistration(ctx *PolicyCmdCtx, cmd *types.RevealRegistr RevealRegistrationResult: &types.RevealRegistrationCmdResult{ Record: r, Event: ev, - Result: types.RegistrationResultStatus_UNARCHIVED, // TODO }, }, }, nil @@ -188,7 +184,7 @@ func (h *Handler) RevealRegistration(ctx *PolicyCmdCtx, cmd *types.RevealRegistr func (h *Handler) FlagHijackAttempt(ctx *PolicyCmdCtx, cmd *types.FlagHijackAttemptCmd) (*types.PolicyCmdResult, error) { actor := coretypes.NewActor(ctx.PrincipalDID) - event, err := h.eventService.FlagHijackEvent(ctx.SDKCtx, cmd.EventId, actor) + event, err := h.eventService.FlagHijackEvent(ctx.Ctx, cmd.EventId, actor) if err != nil { return nil, err } @@ -203,11 +199,11 @@ func (h *Handler) FlagHijackAttempt(ctx *PolicyCmdCtx, cmd *types.FlagHijackAtte func (h *Handler) UnarchiveObject(ctx *PolicyCmdCtx, cmd *types.UnarchiveObjectCmd) (*types.PolicyCmdResult, error) { actor := coretypes.NewActor(ctx.PrincipalDID) - rec, ev, err := h.registrationService.UnarchiveObject(ctx.SDKCtx, ctx.PolicyId, cmd.Object, actor, ctx.Signer) + rec, ev, err := h.registrationService.UnarchiveObject(ctx.Ctx, ctx.PolicyId, cmd.Object, actor, ctx.Signer) if err != nil { return nil, err } - r, err := MapRelationshipRecord(rec) + r, err := types.MapRelationshipRecord(rec) if err != nil { return nil, err } diff --git a/x/acp/policy_cmd/mapper.go b/x/acp/policy_cmd/mapper.go deleted file mode 100644 index 3f77f77d..00000000 --- a/x/acp/policy_cmd/mapper.go +++ /dev/null @@ -1,22 +0,0 @@ -package policy_cmd - -import ( - "github.com/sourcenetwork/acp_core/pkg/errors" - coretypes "github.com/sourcenetwork/acp_core/pkg/types" - "github.com/sourcenetwork/sourcehub/x/acp/types" -) - -func MapRelationshipRecord(rec *coretypes.RelationshipRecord) (*types.RelationshipRecord, error) { - metadata := &types.RecordMetadata{} - err := metadata.Unmarshal(rec.Metadata.Supplied.Blob) - if err != nil { - return nil, errors.Wrap("unmarshaling record metadata", err) - } - - return &types.RelationshipRecord{ - PolicyId: rec.PolicyId, - Archived: rec.Archived, - Relationship: rec.Relationship, - Metadata: metadata, - }, nil -} diff --git a/x/acp/policy_cmd/types.go b/x/acp/policy_cmd/types.go index 041dd8d3..40c93266 100644 --- a/x/acp/policy_cmd/types.go +++ b/x/acp/policy_cmd/types.go @@ -1,19 +1,31 @@ package policy_cmd import ( - "context" - sdk "github.com/cosmos/cosmos-sdk/types" - prototypes "github.com/cosmos/gogoproto/types" "github.com/sourcenetwork/sourcehub/x/acp/types" ) +func NewPolicyCmdCtx(ctx sdk.Context, policyId string, actorDID string, signer string, params types.Params) (PolicyCmdCtx, error) { + ts, err := types.TimestampFromCtx(ctx) + if err != nil { + return PolicyCmdCtx{}, err + } + + return PolicyCmdCtx{ + Ctx: ctx, + PolicyId: policyId, + PrincipalDID: actorDID, + Now: ts, + Params: params, + Signer: signer, + }, nil +} + type PolicyCmdCtx struct { - PolicyId string - PrincipalDID string - Now *prototypes.Timestamp - SDKCtx sdk.Context - EngineContext context.Context - Params types.Params - Signer string + Ctx sdk.Context + PolicyId string + PrincipalDID string + Now *types.Timestamp + Params types.Params + Signer string } diff --git a/x/acp/registration/errors.go b/x/acp/registration/errors.go index 1627479b..0e3ed0b8 100644 --- a/x/acp/registration/errors.go +++ b/x/acp/registration/errors.go @@ -1,14 +1 @@ package registration - -import ( - "fmt" - - "github.com/sourcenetwork/acp_core/pkg/errors" - "github.com/sourcenetwork/sourcehub/x/acp/types" -) - -func errInvalidCommitment(policy string, commitment []byte) error { - return types.New(fmt.Sprintf("invalid commitment: got %v: want %v", len(commitment), commitmentLen), - types.ErrorType_BAD_INPUT, - errors.Pair("policy", policy)) -} diff --git a/x/acp/registration/service.go b/x/acp/registration/service.go index 4adabb39..e3fbfbef 100644 --- a/x/acp/registration/service.go +++ b/x/acp/registration/service.go @@ -4,14 +4,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sourcenetwork/acp_core/pkg/auth" "github.com/sourcenetwork/acp_core/pkg/errors" + "github.com/sourcenetwork/acp_core/pkg/services" coretypes "github.com/sourcenetwork/acp_core/pkg/types" + "github.com/sourcenetwork/sourcehub/x/acp/commitment" "github.com/sourcenetwork/sourcehub/x/acp/types" "github.com/sourcenetwork/sourcehub/x/acp/utils" ) -// commitmentLen is a Sha256 Hash, meaning we expect 32 bytes -const commitmentLen int = 256 / 8 - func NewEventService(repo RegistrationEventRepository) *EventService { return &EventService{ repo: repo, @@ -83,20 +82,21 @@ func (s *EventService) FlagHijackEvent(ctx sdk.Context, eventId uint64, actor *c return event, nil } -func NewRegistrationService(engine coretypes.ACPEngineServer, eventService *EventService, repo CommitmentRepository) *RegistrationService { +func NewRegistrationService(engine *services.EngineService, eventService *EventService, repo commitment.CommitmentRepository, commitmentService commitment.CommitmentService) *RegistrationService { return &RegistrationService{ - engine: engine, - eventService: eventService, - repository: repo, + engine: engine, + eventService: eventService, + repository: repo, + commitmentService: commitmentService, } } // RegistrationService abstracts object registration operations type RegistrationService struct { - engine coretypes.ACPEngineServer + engine *services.EngineService eventService *EventService - repository CommitmentRepository - commitmentService *CommitmentService + repository commitment.CommitmentRepository + commitmentService commitment.CommitmentService } // UnarchiveObject flags a given object as active, effectively re-establishing the owner relationship. @@ -187,7 +187,7 @@ func (s *RegistrationService) registerWithEvent(ctx sdk.Context, polId string, o return nil, nil, err } - metadata, err := utils.BuildACPSuppliedMetadata(ctx, actor.Id, msgCreator) + metadata, err := types.BuildACPSuppliedMetadata(ctx, actor.Id, msgCreator) if err != nil { return nil, nil, err } @@ -301,175 +301,38 @@ func (s *RegistrationService) RevealRegistration(ctx sdk.Context, commitmentId u } if !registrationRecord.IsRegistered { - detail := &types.EventDetail{ - Detail: &types.EventDetail_RevealEvent{ - RevealEvent: &types.RevealRegistrationDetail{ - CommitmentTimestamp: commitment.Metadata.CreationTs, - RegistrationCommitmentId: commitment.Id, - }, - }, - } - // FIXME this is a problem, i need to fiddle with the current timestamp - // which means i'll have to fiddle with the engine and the time service - panic("fixme") - return s.registerWithEvent(ctx, commitment.PolicyId, proof.Object, actor, msgSigner, types.ObjectRegistrationEventType_REVEAL_REGISTRATION, detail) - } - - return s.amendRegistration(ctx, commitment, registrationRecord.Record, actor, msgSigner) -} - -// CommitmentService abstracts registration commitment operations -type CommitmentService struct { - engine coretypes.ACPEngineServer - eventService *EventService - repository CommitmentRepository -} - -// BuildCommitment produces a byte commitment for actor and objects. -// The commitment is guaranteed to be valid, as we verify that no object has been registered yet. -func (s *CommitmentService) BuildCommitment(ctx sdk.Context, policyId string, actor *coretypes.Actor, objects []*coretypes.Object) ([]byte, error) { - rec, err := s.engine.GetPolicy(ctx, &coretypes.GetPolicyRequest{ - Id: policyId, - }) - if err != nil { - return nil, err - } - if rec == nil { - return nil, errors.ErrPolicyNotFound(policyId) - } - - for _, obj := range objects { - status, err := s.engine.GetObjectRegistration(ctx, &coretypes.GetObjectRegistrationRequest{ - PolicyId: policyId, - Object: obj, - }) - if err != nil { - return nil, err - } - if status.IsRegistered { - return nil, errors.Wrap("object already registered", errors.ErrorType_BAD_INPUT, - errors.Pair("policy", policyId), - errors.Pair("resource", obj.Resource), - errors.Pair("object", obj.Id), - ) - } - } - - return GenerateCommitmentWithoutValidation(policyId, actor, objects) -} - -// FlagExpiredCommitments iterates over stored commitments, -// filters for expired commitments wrt the current block time, -// flags them as expired and returns the newly expired commitments -func (s *CommitmentService) FlagExpiredCommitments(ctx sdk.Context) ([]*types.RegistrationsCommitment, error) { - now, err := types.TimestampFromCtx(ctx) - if err != nil { - return nil, err - } - iter, err := s.repository.GetNonExpiredCommitments(ctx) - if err != nil { - return nil, err - } - defer iter.Close() - - var processed []*types.RegistrationsCommitment - for !iter.Finished() { - commitment, err := iter.Value() - if err != nil { - return nil, err - } - expired, err := commitment.IsExpiredAgainst(now) + metadata, err := types.BuildACPSuppliedMetadata(ctx, actor.Id, msgSigner) if err != nil { - return nil, err - } - if expired { - commitment.Expired = true - processed = append(processed, commitment) + return nil, nil, err } - err = iter.Next(ctx) + result, err := s.engine.RevealRegistration(ctx, &coretypes.RevealRegistrationRequest{ + PolicyId: commitment.PolicyId, + Object: proof.Object, + Metadata: metadata, + }) if err != nil { - return nil, err + return nil, nil, err } - } - for _, commitment := range processed { - err := s.repository.Set(ctx, commitment) + ev, err := s.eventService.NewEvent(ctx, + types.ObjectRegistrationEventType_REVEAL_REGISTRATION, + commitment.PolicyId, + proof.Object, + coretypes.NewActor(commitment.Metadata.OwnerDid), + &types.EventDetail{ + Detail: &types.EventDetail_RevealEvent{ + RevealEvent: &types.RevealRegistrationDetail{ + CommitmentTimestamp: commitment.Metadata.CreationTs, + RegistrationCommitmentId: commitment.Id, + }, + }, + }) if err != nil { - return nil, errors.Wrap("expiring commitment", err, errors.Pair("commitment", commitment.Id)) + return nil, nil, err } + return result.Record, ev, nil } - return processed, nil -} - -// SetNewCommitment sets a new RegistrationCommitment -func (s *CommitmentService) SetNewCommitment(ctx sdk.Context, policyId string, commitment []byte, actor *coretypes.Actor, params *types.Params, msgCreator string) (*types.RegistrationsCommitment, error) { - rec, err := s.engine.GetPolicy(ctx, &coretypes.GetPolicyRequest{ - Id: policyId, - }) - if err != nil { - return nil, err - } - if rec == nil { - return nil, errors.ErrPolicyNotFound(policyId) - } - - if len(commitment) != commitmentLen { - return nil, errInvalidCommitment(policyId, commitment) - } - - metadata, err := utils.BuildRecordMetadata(ctx, actor.Id, msgCreator) - if err != nil { - return nil, err - } - - registration := &types.RegistrationsCommitment{ - Id: 0, // doesn't matter since it will be auto-generated - PolicyId: policyId, - Commitment: commitment, - Expired: false, - Validity: params.RegistrationsCommitmentValidity, - Metadata: metadata, - } - - err = s.repository.Create(ctx, registration) - if err != nil { - return nil, err - } - return registration, nil -} - -// ValidateOpening verifies whether the given opening proof is valid for the authenticated actor and -// the objects -// returns true if opening is valid -func (s *CommitmentService) ValidateOpening(ctx sdk.Context, commitmentId uint64, proof *types.RegistrationProof, actor *coretypes.Actor) (bool, error) { - opt, err := s.repository.GetById(ctx, commitmentId) - if err != nil { - return false, err - } - if opt.Empty() { - return false, errors.Wrap("RegistrationsCommimtnet", errors.ErrorType_NOT_FOUND, - errors.Pair("id", commitmentId)) - } - - commitment := opt.GetValue() - now, err := types.TimestampFromCtx(ctx) - if err != nil { - return false, errors.NewFromBaseError(err, errors.ErrorType_INTERNAL, "failed determining current timestamp") - } - after, err := types.IsAfter(commitment.Metadata.CreationTs, commitment.Validity, now) - if err != nil { - return false, errors.NewFromBaseError(err, errors.ErrorType_INTERNAL, "invalid timestmap format") - } - if after { - return false, errors.Wrap("commitment expired", errors.ErrorType_OPERATION_FORBIDDEN, - errors.Pair("commitment", commitmentId)) - } - - ok, err := VerifyProof(commitment.Commitment, commitment.PolicyId, actor, proof) - if err != nil { - return false, errors.Wrap("invalid registration opening", err) - } - return ok, nil + return s.amendRegistration(ctx, commitment, registrationRecord.Record, actor, msgSigner) } diff --git a/x/acp/registration/types.go b/x/acp/registration/types.go index 1c8b6a5c..0dec3693 100644 --- a/x/acp/registration/types.go +++ b/x/acp/registration/types.go @@ -11,21 +11,6 @@ import ( "github.com/sourcenetwork/sourcehub/x/acp/types" ) -type CommitmentRepository interface { - // Create sets a new RegistrationCommitment using the next free up id. - // Sets reg.Id with the effective record Id used. - Create(ctx context.Context, reg *types.RegistrationsCommitment) error - - Set(ctx context.Context, reg *types.RegistrationsCommitment) error - - GetById(ctx context.Context, id uint64) (rctypes.Option[*types.RegistrationsCommitment], error) - - FilterByCommitment(ctx context.Context, commitment []byte) (iterator.Iterator[*types.RegistrationsCommitment], error) - - // GetNonExpiredCommitments returns all commitments whose expiration flag is false - GetNonExpiredCommitments(ctx context.Context) (iterator.Iterator[*types.RegistrationsCommitment], error) -} - type RegistrationEventRepository interface { Set(ctx context.Context, event *types.ObjectRegistrationEvent) error Create(ctx context.Context, event *types.ObjectRegistrationEvent) error diff --git a/x/acp/types/access_decision.go b/x/acp/types/access_decision.go index 09bfd2e5..a6afe7d4 100644 --- a/x/acp/types/access_decision.go +++ b/x/acp/types/access_decision.go @@ -31,7 +31,7 @@ func (decision *AccessDecision) hashDecision() []byte { hasher.Write([]byte(decision.Actor)) hasher.Write([]byte(fmt.Sprintf("%v", decision.CreatorAccSequence))) hasher.Write([]byte(fmt.Sprintf("%v", decision.IssuedHeight))) - hasher.Write([]byte(prototypes.TimestampString(decision.CreationTime))) + hasher.Write([]byte(prototypes.TimestampString(decision.CreationTime.ProtoTs))) for _, operation := range operations { hasher.Write([]byte(operation.Object.Resource)) diff --git a/x/acp/types/access_decision.pb.go b/x/acp/types/access_decision.pb.go index 256d079c..db6aee3d 100644 --- a/x/acp/types/access_decision.pb.go +++ b/x/acp/types/access_decision.pb.go @@ -7,8 +7,8 @@ import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - types "github.com/cosmos/gogoproto/types" - types1 "github.com/sourcenetwork/acp_core/pkg/types" + _ "github.com/cosmos/gogoproto/types" + types "github.com/sourcenetwork/acp_core/pkg/types" io "io" math "math" math_bits "math/bits" @@ -27,14 +27,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // AccessDecision models the result of evaluating a set of AccessRequests for an Actor type AccessDecision struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` - Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` - CreatorAccSequence uint64 `protobuf:"varint,4,opt,name=creator_acc_sequence,json=creatorAccSequence,proto3" json:"creator_acc_sequence,omitempty"` - Operations []*Operation `protobuf:"bytes,5,rep,name=operations,proto3" json:"operations,omitempty"` - Actor string `protobuf:"bytes,6,opt,name=actor,proto3" json:"actor,omitempty"` - Params *DecisionParams `protobuf:"bytes,7,opt,name=params,proto3" json:"params,omitempty"` - CreationTime *types.Timestamp `protobuf:"bytes,8,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` + Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` + CreatorAccSequence uint64 `protobuf:"varint,4,opt,name=creator_acc_sequence,json=creatorAccSequence,proto3" json:"creator_acc_sequence,omitempty"` + Operations []*Operation `protobuf:"bytes,5,rep,name=operations,proto3" json:"operations,omitempty"` + Actor string `protobuf:"bytes,6,opt,name=actor,proto3" json:"actor,omitempty"` + Params *DecisionParams `protobuf:"bytes,7,opt,name=params,proto3" json:"params,omitempty"` + CreationTime *Timestamp `protobuf:"bytes,8,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` // issued_height stores the block height when the Decision was evaluated IssuedHeight uint64 `protobuf:"varint,9,opt,name=issued_height,json=issuedHeight,proto3" json:"issued_height,omitempty"` } @@ -121,7 +121,7 @@ func (m *AccessDecision) GetParams() *DecisionParams { return nil } -func (m *AccessDecision) GetCreationTime() *types.Timestamp { +func (m *AccessDecision) GetCreationTime() *Timestamp { if m != nil { return m.CreationTime } @@ -203,7 +203,7 @@ func (m *DecisionParams) GetTicketExpirationDelta() uint64 { type AccessRequest struct { Operations []*Operation `protobuf:"bytes,1,rep,name=operations,proto3" json:"operations,omitempty"` // actor requesting operations - Actor *types1.Actor `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"` + Actor *types.Actor `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"` } func (m *AccessRequest) Reset() { *m = AccessRequest{} } @@ -246,7 +246,7 @@ func (m *AccessRequest) GetOperations() []*Operation { return nil } -func (m *AccessRequest) GetActor() *types1.Actor { +func (m *AccessRequest) GetActor() *types.Actor { if m != nil { return m.Actor } @@ -256,7 +256,7 @@ func (m *AccessRequest) GetActor() *types1.Actor { // Operation represents an action over an object. type Operation struct { // target object for operation - Object *types1.Object `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` + Object *types.Object `protobuf:"bytes,1,opt,name=object,proto3" json:"object,omitempty"` // permission required to perform operation Permission string `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` } @@ -294,7 +294,7 @@ func (m *Operation) XXX_DiscardUnknown() { var xxx_messageInfo_Operation proto.InternalMessageInfo -func (m *Operation) GetObject() *types1.Object { +func (m *Operation) GetObject() *types.Object { if m != nil { return m.Object } @@ -320,42 +320,42 @@ func init() { } var fileDescriptor_1d553fec1c2b5021 = []byte{ - // 547 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xad, 0xdd, 0x36, 0x6d, 0x26, 0x4d, 0x0e, 0xab, 0x40, 0x4d, 0x10, 0x26, 0x4a, 0x2f, 0xe1, - 0x62, 0xa3, 0x14, 0x2a, 0xc4, 0x05, 0x05, 0x15, 0xa9, 0x9c, 0x8a, 0x0c, 0x27, 0x2e, 0xd6, 0x66, - 0x3d, 0x75, 0x96, 0x26, 0xd9, 0x65, 0x77, 0x23, 0xda, 0x0b, 0xdf, 0xc0, 0xf7, 0xf0, 0x05, 0x1c, - 0x7b, 0xe4, 0x88, 0x92, 0x7f, 0xe0, 0x8c, 0xbc, 0x5e, 0x87, 0x26, 0x15, 0x07, 0x6e, 0xde, 0x79, - 0xef, 0xad, 0x67, 0xde, 0x9b, 0x85, 0x23, 0x2d, 0xe6, 0x8a, 0xe1, 0x78, 0x3e, 0x8a, 0x29, 0x93, - 0x31, 0x65, 0x0c, 0xb5, 0x4e, 0x33, 0x64, 0x5c, 0x73, 0x31, 0x8b, 0xa4, 0x12, 0x46, 0x90, 0xe6, - 0x8a, 0x14, 0x51, 0x26, 0x3b, 0xed, 0x5c, 0xe4, 0xc2, 0x22, 0x71, 0xf1, 0x55, 0x92, 0x3a, 0x8f, - 0x73, 0x21, 0xf2, 0x09, 0xc6, 0xf6, 0x34, 0x9a, 0x5f, 0xc4, 0x86, 0x4f, 0x51, 0x1b, 0x3a, 0x95, - 0x8e, 0xf0, 0xa4, 0xbc, 0x65, 0x86, 0xe6, 0x8b, 0x50, 0x97, 0xc5, 0xef, 0x52, 0x26, 0x14, 0xc6, - 0x0a, 0x27, 0xd4, 0x70, 0x31, 0xd3, 0x63, 0xee, 0xa8, 0xbd, 0xdf, 0x3e, 0xb4, 0x86, 0xb6, 0x95, - 0x53, 0xd7, 0x09, 0x69, 0x81, 0xcf, 0xb3, 0xc0, 0xeb, 0x7a, 0xfd, 0x7a, 0xe2, 0xf3, 0x8c, 0x3c, - 0x84, 0xba, 0x14, 0x13, 0xce, 0xae, 0x53, 0x9e, 0x05, 0xbe, 0x2d, 0xef, 0x97, 0x85, 0xb7, 0x19, - 0x09, 0x60, 0x8f, 0x29, 0xa4, 0x46, 0xa8, 0x60, 0xdb, 0x42, 0xd5, 0x91, 0x3c, 0x85, 0xb6, 0xfb, - 0x4c, 0x29, 0x63, 0xa9, 0xc6, 0xcf, 0x73, 0x9c, 0x31, 0x0c, 0x76, 0xba, 0x5e, 0x7f, 0x27, 0x21, - 0x0e, 0x1b, 0x32, 0xf6, 0xde, 0x21, 0xe4, 0x05, 0x80, 0x90, 0xa8, 0xca, 0x16, 0x83, 0xdd, 0xee, - 0x76, 0xbf, 0x31, 0x08, 0xa2, 0x35, 0x47, 0xa2, 0xf3, 0x8a, 0x90, 0xdc, 0xe2, 0x92, 0x36, 0xec, - 0x52, 0x56, 0xf4, 0x50, 0xb3, 0x3d, 0x94, 0x07, 0xf2, 0x1c, 0x6a, 0x92, 0x2a, 0x3a, 0xd5, 0xc1, - 0x5e, 0xd7, 0xeb, 0x37, 0x06, 0x8f, 0x36, 0xee, 0xaa, 0x26, 0x7e, 0x67, 0x49, 0x89, 0x23, 0x93, - 0x57, 0xd0, 0xb4, 0xcd, 0x71, 0x31, 0x4b, 0x0b, 0x67, 0x83, 0x7d, 0xab, 0xee, 0x44, 0xa5, 0xed, - 0x51, 0x65, 0x7b, 0xf4, 0xa1, 0xb2, 0x3d, 0x39, 0xa8, 0x04, 0x45, 0x89, 0x1c, 0x41, 0x93, 0x6b, - 0x3d, 0xc7, 0x2c, 0x1d, 0x23, 0xcf, 0xc7, 0x26, 0xa8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, - 0x7a, 0x54, 0xb3, 0x2b, 0x73, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x6a, 0x87, 0x32, 0x03, - 0x04, 0x00, 0x00, + // 549 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0xed, 0x6e, 0xd3, 0xb4, 0x71, 0x9a, 0x1c, 0xac, 0x40, 0x4d, 0x11, 0x4b, 0x94, 0x5e, 0xc2, + 0x65, 0x17, 0xa5, 0x50, 0x21, 0x24, 0x0e, 0x41, 0x45, 0x2a, 0xa7, 0xa2, 0x85, 0x13, 0x97, 0x95, + 0xe3, 0x9d, 0x6e, 0x4c, 0x93, 0xd8, 0xd8, 0x8e, 0x68, 0x2f, 0x7c, 0x03, 0xdf, 0xc3, 0x17, 0x70, + 0xec, 0x91, 0x23, 0x4a, 0x7e, 0x81, 0x0f, 0x40, 0xb6, 0x77, 0x43, 0x93, 0x8a, 0x03, 0xb7, 0xf5, + 0xbc, 0x37, 0xb3, 0x6f, 0xe6, 0xcd, 0xa0, 0x23, 0x2d, 0xe6, 0x8a, 0xc1, 0x78, 0x3e, 0x4a, 0x28, + 0x93, 0x09, 0x65, 0x0c, 0xb4, 0xce, 0x72, 0x60, 0x5c, 0x73, 0x31, 0x8b, 0xa5, 0x12, 0x46, 0xe0, + 0xd6, 0x8a, 0x14, 0x53, 0x26, 0x0f, 0x3b, 0x85, 0x28, 0x84, 0x43, 0x12, 0xfb, 0xe5, 0x49, 0x87, + 0x8f, 0x0b, 0x21, 0x8a, 0x09, 0x24, 0xee, 0x35, 0x9a, 0x5f, 0x24, 0x86, 0x4f, 0x41, 0x1b, 0x3a, + 0x95, 0x25, 0xe1, 0x89, 0xaf, 0x32, 0x03, 0xf3, 0x45, 0xa8, 0x4b, 0xfb, 0xbb, 0x8c, 0x09, 0x05, + 0x89, 0x82,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0x57, 0xfe, 0xce, 0xae, + 0x25, 0xe8, 0x51, 0xdd, 0x5d, 0xda, 0xf1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x40, 0xb6, + 0xc8, 0x1b, 0x04, 0x00, 0x00, } func (m *AccessDecision) Marshal() (dAtA []byte, err error) { @@ -978,7 +978,7 @@ func (m *AccessDecision) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.CreationTime == nil { - m.CreationTime = &types.Timestamp{} + m.CreationTime = &Timestamp{} } if err := m.CreationTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1224,7 +1224,7 @@ func (m *AccessRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Actor == nil { - m.Actor = &types1.Actor{} + m.Actor = &types.Actor{} } if err := m.Actor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1310,7 +1310,7 @@ func (m *Operation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Object == nil { - m.Object = &types1.Object{} + m.Object = &types.Object{} } if err := m.Object.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/acp/types/mapper.go b/x/acp/types/mapper.go new file mode 100644 index 00000000..fd6acac7 --- /dev/null +++ b/x/acp/types/mapper.go @@ -0,0 +1,75 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sourcenetwork/acp_core/pkg/errors" + coretypes "github.com/sourcenetwork/acp_core/pkg/types" + "github.com/sourcenetwork/sourcehub/x/acp/utils" +) + +func BuildRecordMetadata(ctx sdk.Context, actorDID string, msgCreator string) (*RecordMetadata, error) { + ts, err := TimestampFromCtx(ctx) + if err != nil { + return nil, err + } + dt := &RecordMetadata{ + CreationTs: ts, + TxHash: utils.HashTx(ctx.TxBytes()), + OwnerDid: actorDID, + TxSigner: msgCreator, + } + return dt, nil +} + +func BuildACPSuppliedMetadata(ctx sdk.Context, actorDID string, msgCreator string) (*coretypes.SuppliedMetadata, error) { + rm, err := BuildRecordMetadata(ctx, actorDID, msgCreator) + if err != nil { + return nil, err + } + bytes, err := rm.Marshal() + if err != nil { + return nil, err + } + return &coretypes.SuppliedMetadata{ + Blob: bytes, + }, nil +} + +func UmarshalRecordMetadata(md *coretypes.RecordMetadata) (*RecordMetadata, error) { + metadata := &RecordMetadata{} + err := metadata.Unmarshal(md.Supplied.Blob) + if err != nil { + return nil, errors.Wrap("unmarshaling record metadata", err) + } + return metadata, nil +} + +func MapRelationshipRecord(rec *coretypes.RelationshipRecord) (*RelationshipRecord, error) { + metadata := &RecordMetadata{} + err := metadata.Unmarshal(rec.Metadata.Supplied.Blob) + if err != nil { + return nil, errors.Wrap("unmarshaling record metadata", err) + } + + return &RelationshipRecord{ + PolicyId: rec.PolicyId, + Archived: rec.Archived, + Relationship: rec.Relationship, + Metadata: metadata, + }, nil +} + +func MapPolicy(rec *coretypes.PolicyRecord) (*PolicyRecord, error) { + metadata := &RecordMetadata{} + err := metadata.Unmarshal(rec.Metadata.Supplied.Blob) + if err != nil { + return nil, errors.Wrap("unmarshaling record metadata", err) + } + + return &PolicyRecord{ + Policy: rec.Policy, + Metadata: metadata, + MarshalType: rec.MarshalType, + RawPolicy: rec.PolicyDefinition, + }, nil +} diff --git a/x/acp/types/message_bearer_policy_cmd.go b/x/acp/types/message_bearer_policy_cmd.go index 28ed1b99..2651a891 100644 --- a/x/acp/types/message_bearer_policy_cmd.go +++ b/x/acp/types/message_bearer_policy_cmd.go @@ -2,27 +2,15 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - prototypes "github.com/cosmos/gogoproto/types" ) var _ sdk.Msg = &MsgDirectPolicyCmd{} -func NewMsgBearerPolicyCmd(creator string, token string, policyId string, cmd *PolicyCmd, ts *prototypes.Timestamp) *MsgBearerPolicyCmd { +func NewMsgBearerPolicyCmd(creator string, token string, policyId string, cmd *PolicyCmd) *MsgBearerPolicyCmd { return &MsgBearerPolicyCmd{ - Creator: creator, - BearerToken: token, - PolicyId: policyId, - Cmd: cmd, - CreationTime: ts, - } -} - -func NewMsgBearerPolicyCmdNow(creator string, token string, policyId string, cmd *PolicyCmd) *MsgBearerPolicyCmd { - return &MsgBearerPolicyCmd{ - Creator: creator, - BearerToken: token, - PolicyId: policyId, - Cmd: cmd, - CreationTime: prototypes.TimestampNow(), + Creator: creator, + BearerToken: token, + PolicyId: policyId, + Cmd: cmd, } } diff --git a/x/acp/types/message_create_policy.go b/x/acp/types/message_create_policy.go index 84bc7984..4235a53f 100644 --- a/x/acp/types/message_create_policy.go +++ b/x/acp/types/message_create_policy.go @@ -4,26 +4,19 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - prototypes "github.com/cosmos/gogoproto/types" acptypes "github.com/sourcenetwork/acp_core/pkg/types" ) var _ sdk.Msg = &MsgCreatePolicy{} -func NewMsgCreatePolicy(creator string, policy string, marshalingType acptypes.PolicyMarshalingType, creationTime *prototypes.Timestamp) *MsgCreatePolicy { +func NewMsgCreatePolicy(creator string, policy string, marshalingType acptypes.PolicyMarshalingType) *MsgCreatePolicy { return &MsgCreatePolicy{ - Creator: creator, - Policy: policy, - MarshalType: marshalingType, - CreationTime: creationTime, + Creator: creator, + Policy: policy, + MarshalType: marshalingType, } } -// NewMsgCreatePolicyNow creates a MsgCreatePolicy with CreatedAt set to the current time -func NewMsgCreatePolicyNow(creator string, policy string, marshalingType acptypes.PolicyMarshalingType) *MsgCreatePolicy { - return NewMsgCreatePolicy(creator, policy, marshalingType, prototypes.TimestampNow()) -} - func (msg *MsgCreatePolicy) ValidateBasic() error { // ValidateBasic should probably unmarshal the policy and validate it _, err := sdk.AccAddressFromBech32(msg.Creator) diff --git a/x/acp/types/message_direct_policy_cmd.go b/x/acp/types/message_direct_policy_cmd.go index 39d6af14..6b2328cc 100644 --- a/x/acp/types/message_direct_policy_cmd.go +++ b/x/acp/types/message_direct_policy_cmd.go @@ -2,25 +2,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - prototypes "github.com/cosmos/gogoproto/types" ) var _ sdk.Msg = &MsgDirectPolicyCmd{} -func NewMsgDirectPolicyCmd(creator string, policyId string, cmd *PolicyCmd, ts *prototypes.Timestamp) *MsgDirectPolicyCmd { +func NewMsgDirectPolicyCmd(creator string, policyId string, cmd *PolicyCmd) *MsgDirectPolicyCmd { return &MsgDirectPolicyCmd{ - Creator: creator, - PolicyId: policyId, - Cmd: cmd, - CreationTime: ts, - } -} - -func NewMsgDirectPolicyCmdNow(creator string, policyId string, cmd *PolicyCmd) *MsgDirectPolicyCmd { - return &MsgDirectPolicyCmd{ - Creator: creator, - PolicyId: policyId, - Cmd: cmd, - CreationTime: prototypes.TimestampNow(), + Creator: creator, + PolicyId: policyId, + Cmd: cmd, } } diff --git a/x/acp/types/policy_cmd.pb.go b/x/acp/types/policy_cmd.pb.go index cf877ceb..d581633a 100644 --- a/x/acp/types/policy_cmd.pb.go +++ b/x/acp/types/policy_cmd.pb.go @@ -24,34 +24,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type RevealRegistrationResult int32 - -const ( - RevealRegistrationResult_NO_OP RevealRegistrationResult = 0 - RevealRegistrationResult_CREATED RevealRegistrationResult = 1 - RevealRegistrationResult_AMENDED RevealRegistrationResult = 2 -) - -var RevealRegistrationResult_name = map[int32]string{ - 0: "NO_OP", - 1: "CREATED", - 2: "AMENDED", -} - -var RevealRegistrationResult_value = map[string]int32{ - "NO_OP": 0, - "CREATED": 1, - "AMENDED": 2, -} - -func (x RevealRegistrationResult) String() string { - return proto.EnumName(RevealRegistrationResult_name, int32(x)) -} - -func (RevealRegistrationResult) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_1de5e9736122d1ff, []int{0} -} - // SignedPolicyCmd represents a Command issued by an Actor in the context of a Policy // The command represents an instruction to be executed // The message type contains a signature which is used to authenticate the Command's Actor @@ -652,9 +624,8 @@ func (m *RevealRegistrationCmd) GetProof() *RegistrationProof { } type RevealRegistrationCmdResult struct { - Result RevealRegistrationResult `protobuf:"varint,1,opt,name=result,proto3,enum=sourcehub.acp.RevealRegistrationResult" json:"result,omitempty"` - Record *RelationshipRecord `protobuf:"bytes,2,opt,name=record,proto3" json:"record,omitempty"` - Event *ObjectRegistrationEvent `protobuf:"bytes,3,opt,name=event,proto3" json:"event,omitempty"` + Record *RelationshipRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"` + Event *ObjectRegistrationEvent `protobuf:"bytes,2,opt,name=event,proto3" json:"event,omitempty"` } func (m *RevealRegistrationCmdResult) Reset() { *m = RevealRegistrationCmdResult{} } @@ -690,13 +661,6 @@ func (m *RevealRegistrationCmdResult) XXX_DiscardUnknown() { var xxx_messageInfo_RevealRegistrationCmdResult proto.InternalMessageInfo -func (m *RevealRegistrationCmdResult) GetResult() RevealRegistrationResult { - if m != nil { - return m.Result - } - return RevealRegistrationResult_NO_OP -} - func (m *RevealRegistrationCmdResult) GetRecord() *RelationshipRecord { if m != nil { return m.Record @@ -1313,7 +1277,6 @@ func (*PolicyCmdResult) XXX_OneofWrappers() []interface{} { } func init() { - proto.RegisterEnum("sourcehub.acp.RevealRegistrationResult", RevealRegistrationResult_name, RevealRegistrationResult_value) proto.RegisterType((*SignedPolicyCmd)(nil), "sourcehub.acp.SignedPolicyCmd") proto.RegisterType((*SignedPolicyCmdPayload)(nil), "sourcehub.acp.SignedPolicyCmdPayload") proto.RegisterType((*PolicyCmd)(nil), "sourcehub.acp.PolicyCmd") @@ -1339,84 +1302,81 @@ func init() { func init() { proto.RegisterFile("sourcehub/acp/policy_cmd.proto", fileDescriptor_1de5e9736122d1ff) } var fileDescriptor_1de5e9736122d1ff = []byte{ - // 1231 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdf, 0x4f, 0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d, 0x9d, 0xda, 0xd6, 0xa4, 0x9b, 0xbc, 0xb2, 0xa1, 0xa7, 0x4d, 0x59, 0xd6, 0xd0, 0x89, 0xb5, - 0x4d, 0x28, 0x76, 0xf2, 0xc3, 0x27, 0x73, 0x73, 0x1b, 0xf4, 0x69, 0xef, 0x23, 0x2a, 0x40, 0xf6, - 0xc5, 0x81, 0x79, 0x70, 0x58, 0xcc, 0xa0, 0x05, 0x98, 0xdf, 0xc5, 0xcd, 0xc6, 0x51, 0x73, 0xaf, - 0xa8, 0xb1, 0x3f, 0x8d, 0xe7, 0xcd, 0x17, 0x7b, 0xcd, 0xbd, 0xe2, 0xcc, 0x4e, 0xeb, 0xb7, 0xcb, - 0xaa, 0xf6, 0xe6, 0xb2, 0xaa, 0xfd, 0x75, 0x59, 0xd5, 0x7e, 0xbd, 0xaa, 0x66, 0xde, 0x5c, 0x55, - 0x33, 0x7f, 0x5e, 0x55, 0x33, 0xaf, 0x6a, 0x1d, 0x97, 0xb2, 0x10, 0x6d, 0xdf, 0xab, 0x4f, 0x7e, - 0x09, 0x8f, 0x3f, 0x55, 0xcf, 0xf9, 0xc7, 0x2a, 0xbd, 0x08, 0x48, 0x74, 0x92, 0xe3, 0x9f, 0x70, - 0x4f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x94, 0x36, 0xe2, 0x9c, 0x87, 0x0f, 0x00, 0x00, + // 1174 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcd, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xa6, 0xb1, 0xe3, 0xbc, 0x24, 0x24, 0x9d, 0x3a, 0xf1, 0xc6, 0xa9, 0xdc, 0x74, 0xdb, + 0x42, 0x53, 0x24, 0x5b, 0xb4, 0x12, 0x1f, 0x12, 0x02, 0xd2, 0xb4, 0x95, 0xc3, 0x87, 0x1a, 0x0d, + 0xed, 0xa5, 0xa0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0x3b, 0x74, 0xf2, 0xa1, 0x78, 0x22, 0x3f, 0x15, 0xf9, 0x69, + 0x44, 0x93, 0xc3, 0xb2, 0xfc, 0x80, 0x7a, 0xf0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc6, 0x15, + 0xbe, 0x91, 0x05, 0x0f, 0x00, 0x00, } func (m *SignedPolicyCmd) Marshal() (dAtA []byte, err error) { @@ -1972,7 +1932,7 @@ func (m *RevealRegistrationCmdResult) MarshalToSizedBuffer(dAtA []byte) (int, er i = encodeVarintPolicyCmd(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if m.Record != nil { { @@ -1984,12 +1944,7 @@ func (m *RevealRegistrationCmdResult) MarshalToSizedBuffer(dAtA []byte) (int, er i = encodeVarintPolicyCmd(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - } - if m.Result != 0 { - i = encodeVarintPolicyCmd(dAtA, i, uint64(m.Result)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -2777,9 +2732,6 @@ func (m *RevealRegistrationCmdResult) Size() (n int) { } var l int _ = l - if m.Result != 0 { - n += 1 + sovPolicyCmd(uint64(m.Result)) - } if m.Record != nil { l = m.Record.Size() n += 1 + l + sovPolicyCmd(uint64(l)) @@ -4266,25 +4218,6 @@ func (m *RevealRegistrationCmdResult) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - m.Result = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPolicyCmd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Result |= RevealRegistrationResult(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Record", wireType) } @@ -4320,7 +4253,7 @@ func (m *RevealRegistrationCmdResult) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Event", wireType) } diff --git a/x/acp/types/tx.pb.go b/x/acp/types/tx.pb.go index 04177ea2..05457f24 100644 --- a/x/acp/types/tx.pb.go +++ b/x/acp/types/tx.pb.go @@ -12,7 +12,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - types1 "github.com/cosmos/gogoproto/types" + _ "github.com/cosmos/gogoproto/types" types "github.com/sourcenetwork/acp_core/pkg/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -152,10 +152,9 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo type MsgCreatePolicy struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Policy string `protobuf:"bytes,2,opt,name=policy,proto3" json:"policy,omitempty"` - MarshalType types.PolicyMarshalingType `protobuf:"varint,3,opt,name=marshal_type,json=marshalType,proto3,enum=sourcenetwork.acp_core.PolicyMarshalingType" json:"marshal_type,omitempty"` - CreationTime *types1.Timestamp `protobuf:"bytes,4,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Policy string `protobuf:"bytes,2,opt,name=policy,proto3" json:"policy,omitempty"` + MarshalType types.PolicyMarshalingType `protobuf:"varint,3,opt,name=marshal_type,json=marshalType,proto3,enum=sourcenetwork.acp_core.PolicyMarshalingType" json:"marshal_type,omitempty"` } func (m *MsgCreatePolicy) Reset() { *m = MsgCreatePolicy{} } @@ -212,13 +211,6 @@ func (m *MsgCreatePolicy) GetMarshalType() types.PolicyMarshalingType { return types.PolicyMarshalingType_UNKNOWN } -func (m *MsgCreatePolicy) GetCreationTime() *types1.Timestamp { - if m != nil { - return m.CreationTime - } - return nil -} - type MsgCreatePolicyResponse struct { Record *PolicyRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"` } @@ -264,10 +256,9 @@ func (m *MsgCreatePolicyResponse) GetRecord() *PolicyRecord { } type MsgCheckAccess struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` - CreationTime *types1.Timestamp `protobuf:"bytes,3,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` - AccessRequest *AccessRequest `protobuf:"bytes,4,opt,name=access_request,json=accessRequest,proto3" json:"access_request,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` + AccessRequest *AccessRequest `protobuf:"bytes,3,opt,name=access_request,json=accessRequest,proto3" json:"access_request,omitempty"` } func (m *MsgCheckAccess) Reset() { *m = MsgCheckAccess{} } @@ -317,13 +308,6 @@ func (m *MsgCheckAccess) GetPolicyId() string { return "" } -func (m *MsgCheckAccess) GetCreationTime() *types1.Timestamp { - if m != nil { - return m.CreationTime - } - return nil -} - func (m *MsgCheckAccess) GetAccessRequest() *AccessRequest { if m != nil { return m.AccessRequest @@ -480,11 +464,10 @@ func (m *MsgSignedPolicyCmdResponse) GetResult() *PolicyCmdResult { } type MsgBearerPolicyCmd struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - BearerToken string `protobuf:"bytes,2,opt,name=bearer_token,json=bearerToken,proto3" json:"bearer_token,omitempty"` - PolicyId string `protobuf:"bytes,3,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` - Cmd *PolicyCmd `protobuf:"bytes,4,opt,name=cmd,proto3" json:"cmd,omitempty"` - CreationTime *types1.Timestamp `protobuf:"bytes,5,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + BearerToken string `protobuf:"bytes,2,opt,name=bearer_token,json=bearerToken,proto3" json:"bearer_token,omitempty"` + PolicyId string `protobuf:"bytes,3,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` + Cmd *PolicyCmd `protobuf:"bytes,4,opt,name=cmd,proto3" json:"cmd,omitempty"` } func (m *MsgBearerPolicyCmd) Reset() { *m = MsgBearerPolicyCmd{} } @@ -548,13 +531,6 @@ func (m *MsgBearerPolicyCmd) GetCmd() *PolicyCmd { return nil } -func (m *MsgBearerPolicyCmd) GetCreationTime() *types1.Timestamp { - if m != nil { - return m.CreationTime - } - return nil -} - type MsgBearerPolicyCmdResponse struct { Result *PolicyCmdResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } @@ -600,10 +576,9 @@ func (m *MsgBearerPolicyCmdResponse) GetResult() *PolicyCmdResult { } type MsgDirectPolicyCmd struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` - Cmd *PolicyCmd `protobuf:"bytes,3,opt,name=cmd,proto3" json:"cmd,omitempty"` - CreationTime *types1.Timestamp `protobuf:"bytes,4,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + PolicyId string `protobuf:"bytes,2,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` + Cmd *PolicyCmd `protobuf:"bytes,3,opt,name=cmd,proto3" json:"cmd,omitempty"` } func (m *MsgDirectPolicyCmd) Reset() { *m = MsgDirectPolicyCmd{} } @@ -660,13 +635,6 @@ func (m *MsgDirectPolicyCmd) GetCmd() *PolicyCmd { return nil } -func (m *MsgDirectPolicyCmd) GetCreationTime() *types1.Timestamp { - if m != nil { - return m.CreationTime - } - return nil -} - type MsgDirectPolicyCmdResponse struct { Result *PolicyCmdResult `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } @@ -730,65 +698,62 @@ func init() { func init() { proto.RegisterFile("sourcehub/acp/tx.proto", fileDescriptor_5bb2974ac27b9ccc) } var fileDescriptor_5bb2974ac27b9ccc = []byte{ - // 924 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6f, 0xdc, 0x44, - 0x14, 0x5f, 0xb3, 0x69, 0xd2, 0x9d, 0xdd, 0x24, 0xc5, 0x2a, 0xe9, 0xd6, 0xa5, 0x4e, 0xea, 0x0a, - 0x94, 0x46, 0xd4, 0x16, 0x5b, 0xa9, 0x82, 0x5e, 0x50, 0x92, 0x1e, 0xf8, 0x50, 0x52, 0xe4, 0x4d, - 0x5b, 0x89, 0x8b, 0xe5, 0x8c, 0x07, 0xaf, 0x95, 0xb5, 0xc7, 0xcc, 0xcc, 0x42, 0xf7, 0x86, 0x38, - 0x72, 0xe2, 0xcf, 0xe0, 0x98, 0x43, 0x25, 0x6e, 0x1c, 0x51, 0x8f, 0x15, 0x27, 0x24, 0x24, 0x84, - 0x92, 0x43, 0xc4, 0x7f, 0x81, 0xe6, 0xc3, 0x1b, 0x7b, 0xd6, 0xbb, 0x2d, 0xa4, 0x97, 0x64, 0xdf, - 0x7b, 0xbf, 0x79, 0x1f, 0x3f, 0xff, 0xde, 0xd8, 0x60, 0x8d, 0xe2, 0x11, 0x81, 0x68, 0x30, 0x3a, - 0xf4, 0x42, 0x98, 0x7b, 0xec, 0x99, 0x9b, 0x13, 0xcc, 0xb0, 0xb9, 0x3c, 0xf1, 0xbb, 0x21, 0xcc, - 0xad, 0xb7, 0xc3, 0x34, 0xc9, 0xb0, 0x27, 0xfe, 0x4a, 0x84, 0x75, 0x0d, 0x62, 0x9a, 0x62, 0xea, - 0xa5, 0x34, 0xf6, 0xbe, 0xfd, 0x90, 0xff, 0x53, 0x81, 0xeb, 0x32, 0x10, 0x08, 0xcb, 0x93, 0x86, - 0x0a, 0x5d, 0x8d, 0x71, 0x8c, 0xa5, 0x9f, 0xff, 0x52, 0xde, 0xf5, 0x18, 0xe3, 0x78, 0x88, 0x3c, - 0x61, 0x1d, 0x8e, 0xbe, 0xf6, 0x58, 0x92, 0x22, 0xca, 0xc2, 0x34, 0x57, 0x80, 0xdb, 0xd5, 0x26, - 0x43, 0x08, 0x11, 0xa5, 0x41, 0x84, 0x60, 0x42, 0x13, 0x9c, 0x29, 0x90, 0x55, 0x05, 0xe5, 0x21, - 0x09, 0xd3, 0xa2, 0xae, 0xad, 0xc5, 0xf0, 0x30, 0x81, 0xe3, 0x00, 0xa6, 0x51, 0xfd, 0x59, 0x82, - 0x20, 0x26, 0x45, 0xec, 0x8e, 0x8c, 0x65, 0x88, 0x7d, 0x87, 0xc9, 0x11, 0x8f, 0x07, 0x10, 0x13, - 0x54, 0x24, 0xa1, 0x03, 0x4c, 0x58, 0xb5, 0xcf, 0x19, 0x50, 0x09, 0x72, 0x7e, 0x31, 0xc0, 0xea, - 0x1e, 0x8d, 0x1f, 0xe7, 0x51, 0xc8, 0xd0, 0x97, 0xa2, 0x4b, 0xf3, 0x3e, 0x68, 0x85, 0x23, 0x36, - 0xc0, 0x24, 0x61, 0xe3, 0xae, 0xb1, 0x61, 0x6c, 0xb6, 0x76, 0xba, 0xbf, 0x3f, 0xbf, 0x7b, 0x55, - 0x91, 0xb7, 0x1d, 0x45, 0x04, 0x51, 0xda, 0x67, 0x24, 0xc9, 0x62, 0xff, 0x1c, 0x6a, 0x7e, 0x04, - 0x16, 0xe5, 0x9c, 0xdd, 0xb7, 0x36, 0x8c, 0xcd, 0x76, 0xef, 0x1d, 0xb7, 0xf2, 0xd8, 0x5c, 0x99, - 0x7e, 0xa7, 0xf5, 0xe2, 0xaf, 0xf5, 0xc6, 0xcf, 0x67, 0xc7, 0x5b, 0x86, 0xaf, 0xf0, 0x0f, 0x7a, - 0x3f, 0x9c, 0x1d, 0x6f, 0x9d, 0x67, 0xfa, 0xf1, 0xec, 0x78, 0x6b, 0xfd, 0x9c, 0x84, 0x67, 0x82, - 0x06, 0xad, 0x4b, 0xe7, 0x3a, 0xb8, 0xa6, 0xb9, 0x7c, 0x44, 0x73, 0x9c, 0x51, 0xe4, 0x9c, 0xca, - 0xa1, 0x76, 0x09, 0xe2, 0x31, 0x31, 0xae, 0xd9, 0x05, 0x4b, 0x90, 0xdb, 0x98, 0xc8, 0x91, 0xfc, - 0xc2, 0x34, 0xd7, 0xc0, 0xa2, 0xa4, 0x44, 0xb4, 0xdd, 0xf2, 0x95, 0x65, 0x3e, 0x02, 0x9d, 0x34, - 0x24, 0x74, 0x10, 0x0e, 0x03, 0x36, 0xce, 0x51, 0xb7, 0xb9, 0x61, 0x6c, 0xae, 0xf4, 0x3e, 0x70, - 0x2b, 0xb4, 0xba, 0x05, 0xad, 0xae, 0xac, 0xb3, 0x27, 0x4f, 0x24, 0x59, 0x7c, 0x30, 0xce, 0x91, - 0xdf, 0x56, 0x19, 0xb8, 0x61, 0x7e, 0x02, 0x96, 0x45, 0xcd, 0x04, 0x67, 0x01, 0x17, 0x55, 0x77, - 0x41, 0xd0, 0x64, 0xb9, 0x52, 0x71, 0x6e, 0xa1, 0x38, 0xf7, 0xa0, 0x50, 0x9c, 0xdf, 0x29, 0x0e, - 0x70, 0xd7, 0x83, 0x0e, 0xa7, 0xa9, 0xe8, 0xdb, 0xd9, 0x17, 0x04, 0x94, 0x87, 0x2c, 0x08, 0x30, - 0xef, 0x81, 0x45, 0xa9, 0x1a, 0x31, 0x6b, 0xbb, 0x77, 0x43, 0x7f, 0x12, 0x0a, 0xce, 0x21, 0xbe, - 0x82, 0x3a, 0x7f, 0x1a, 0x60, 0x85, 0x27, 0x1c, 0x20, 0x78, 0xb4, 0x2d, 0x44, 0x3d, 0x87, 0xb4, - 0x1b, 0xa0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0x9d, 0xda, 0x8d, - 0x97, 0xa7, 0x76, 0xe3, 0x8f, 0x53, 0xbb, 0xf1, 0x95, 0x1b, 0x27, 0x8c, 0xe7, 0x81, 0x38, 0xf5, - 0xaa, 0x9f, 0x4d, 0xfa, 0x67, 0x08, 0xbf, 0x69, 0xe9, 0xe1, 0xa2, 0x58, 0x83, 0x7b, 0xff, 0x06, - 0x00, 0x00, 0xff, 0xff, 0x1d, 0xe8, 0xd5, 0x50, 0xb1, 0x0a, 0x00, 0x00, + // 880 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xbf, 0x6f, 0xdb, 0x46, + 0x14, 0x16, 0x2b, 0xd7, 0x8e, 0x8e, 0x8a, 0x9d, 0x12, 0xa9, 0xc3, 0x30, 0x0d, 0xed, 0x30, 0x68, + 0xe1, 0x18, 0x0d, 0x89, 0x2a, 0x40, 0xd0, 0x66, 0xb3, 0x9d, 0xa1, 0x3f, 0x60, 0xa5, 0xa0, 0x9c, + 0x04, 0xe8, 0x42, 0x50, 0xc7, 0x2b, 0x45, 0x58, 0xe4, 0xb1, 0x77, 0xa7, 0x36, 0xda, 0x8a, 0x02, + 0x5d, 0x3a, 0x75, 0xee, 0xd8, 0x29, 0xa3, 0x87, 0x00, 0xdd, 0x3a, 0x67, 0x0c, 0x3a, 0x75, 0x2a, + 0x0a, 0x7b, 0xf0, 0xbf, 0x51, 0xf0, 0xee, 0x28, 0x91, 0x67, 0x4a, 0x09, 0x9a, 0xc5, 0xd6, 0xbb, + 0xf7, 0xdd, 0x7b, 0xdf, 0xf7, 0xdd, 0xbb, 0x93, 0xc0, 0x26, 0xc5, 0x13, 0x02, 0xd1, 0x68, 0x32, + 0xf4, 0x42, 0x98, 0x7b, 0xec, 0x99, 0x9b, 0x13, 0xcc, 0xb0, 0x71, 0x79, 0xb6, 0xee, 0x86, 0x30, + 0xb7, 0xde, 0x0b, 0xd3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, 0xf9, 0x2f, + 0x87, 0x7b, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x37, 0x07, 0x92, 0xad, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1160,18 +1125,6 @@ func (m *MsgCreatePolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.CreationTime != nil { - { - size, err := m.CreationTime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } if m.MarshalType != 0 { i = encodeVarintTx(dAtA, i, uint64(m.MarshalType)) i-- @@ -1259,18 +1212,6 @@ func (m *MsgCheckAccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - } - if m.CreationTime != nil { - { - size, err := m.CreationTime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x1a } if len(m.PolicyId) > 0 { @@ -1422,18 +1363,6 @@ func (m *MsgBearerPolicyCmd) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.CreationTime != nil { - { - size, err := m.CreationTime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } if m.Cmd != nil { { size, err := m.Cmd.MarshalToSizedBuffer(dAtA[:i]) @@ -1525,18 +1454,6 @@ func (m *MsgDirectPolicyCmd) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.CreationTime != nil { - { - size, err := m.CreationTime.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } if m.Cmd != nil { { size, err := m.Cmd.MarshalToSizedBuffer(dAtA[:i]) @@ -1653,10 +1570,6 @@ func (m *MsgCreatePolicy) Size() (n int) { if m.MarshalType != 0 { n += 1 + sovTx(uint64(m.MarshalType)) } - if m.CreationTime != nil { - l = m.CreationTime.Size() - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -1687,10 +1600,6 @@ func (m *MsgCheckAccess) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.CreationTime != nil { - l = m.CreationTime.Size() - n += 1 + l + sovTx(uint64(l)) - } if m.AccessRequest != nil { l = m.AccessRequest.Size() n += 1 + l + sovTx(uint64(l)) @@ -1766,10 +1675,6 @@ func (m *MsgBearerPolicyCmd) Size() (n int) { l = m.Cmd.Size() n += 1 + l + sovTx(uint64(l)) } - if m.CreationTime != nil { - l = m.CreationTime.Size() - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -1804,10 +1709,6 @@ func (m *MsgDirectPolicyCmd) Size() (n int) { l = m.Cmd.Size() n += 1 + l + sovTx(uint64(l)) } - if m.CreationTime != nil { - l = m.CreationTime.Size() - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -2107,42 +2008,6 @@ func (m *MsgCreatePolicy) Unmarshal(dAtA []byte) error { break } } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreationTime == nil { - m.CreationTime = &types1.Timestamp{} - } - if err := m.CreationTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2344,42 +2209,6 @@ func (m *MsgCheckAccess) Unmarshal(dAtA []byte) error { m.PolicyId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreationTime == nil { - m.CreationTime = &types1.Timestamp{} - } - if err := m.CreationTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AccessRequest", wireType) } @@ -2902,42 +2731,6 @@ func (m *MsgBearerPolicyCmd) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreationTime == nil { - m.CreationTime = &types1.Timestamp{} - } - if err := m.CreationTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3174,42 +2967,6 @@ func (m *MsgDirectPolicyCmd) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CreationTime == nil { - m.CreationTime = &types1.Timestamp{} - } - if err := m.CreationTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/acp/utils/utils.go b/x/acp/utils/utils.go index d0d7597b..490c9f83 100644 --- a/x/acp/utils/utils.go +++ b/x/acp/utils/utils.go @@ -6,8 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sourcenetwork/acp_core/pkg/auth" coretypes "github.com/sourcenetwork/acp_core/pkg/types" - - "github.com/sourcenetwork/sourcehub/x/acp/types" ) // HasTx produces a sha256 of a Tx bytes @@ -28,31 +26,3 @@ func InjectPrincipal(ctx sdk.Context, actorDID string) (sdk.Context, error) { ctx = ctx.WithContext(goCtx) return ctx, nil } - -func BuildRecordMetadata(ctx sdk.Context, actorDID string, msgCreator string) (*types.RecordMetadata, error) { - ts, err := types.TimestampFromCtx(ctx) - if err != nil { - return nil, err - } - dt := &types.RecordMetadata{ - CreationTs: ts, - TxHash: HashTx(ctx.TxBytes()), - OwnerDid: actorDID, - TxSigner: msgCreator, - } - return dt, nil -} - -func BuildACPSuppliedMetadata(ctx sdk.Context, actorDID string, msgCreator string) (*coretypes.SuppliedMetadata, error) { - rm, err := BuildRecordMetadata(ctx, actorDID, msgCreator) - if err != nil { - return nil, err - } - bytes, err := rm.Marshal() - if err != nil { - return nil, err - } - return &coretypes.SuppliedMetadata{ - Blob: bytes, - }, nil -}