Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: P-861 add params support for evm dynamic assertion #2812

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

higherordertech
Copy link
Contributor

@higherordertech higherordertech commented Jun 14, 2024

Context

Extra arbitrary number parameters are supported now when callling DynamicAssertion requestVc.

This will be immediately handy when we can deploy one holding amount VC contract containing 40+ token in one go, instead of deploy 40+ times each for each one token VC contract.

And in long run solidity VC will support arbitrary VC parameters which will be very useful too.

It's breaking change to interface but given DA is not live in prod the impact is minimized..

Labels

Please apply following PR-related labels when appropriate:

  • C0-breaking: if your change could break the existing client, e.g. API change, critical logic change
  • C1-noteworthy: if your change is non-breaking, but is still worth noticing for the client, e.g. reference code improvement

How (Optional)

Testing Evidences

Please attach any relevant evidences if applicable

@higherordertech higherordertech requested review from kziemianek, 0xverin, a team and BillyWooo June 14, 2024 09:34
@higherordertech higherordertech added the C0-breaking Breaking change that will cause existing client to break label Jun 14, 2024
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you already have an example how it's used in practice?

cc @jonalvarezz - it's a breaking change too

@@ -135,6 +139,6 @@ contract A6 is DynamicAssertion {
pure
returns (string memory)
{
return concatenateStrings("Bearer ", apiKey);
return string(abi.encodePacked("Bearer ", apiKey));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary unless you want ditch concatenateStrings everywhere

@higherordertech higherordertech force-pushed the P-861-DA-extra-params branch from 4ce6916 to 6a5c3be Compare June 17, 2024 01:58
let truncated_params = DynamicParams::truncate_from(params);
let truncated_params_len = truncated_params.len();
if params_len > truncated_params_len {
println!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be an error? parameter has already got truncated?

@higherordertech
Copy link
Contributor Author

higherordertech commented Jun 17, 2024

Thanks! Do you already have an example how it's used in practice?

cc @jonalvarezz - it's a breaking change too

We will use the extra token name parameter in this open PR: #2811

However below I did test the regression flow for the existing solidity VC just to be sure it doesn't break existing ones (which doesn't ask for the extra paramaters yet) either:

scripts:

// link
./bin/litentry-cli trusted -d link-identity did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 did:litentry:evm:0x83067bAE0D4468455948B87DEe5B2585de331B7D bsc


// params[0]=ordi
./bin/litentry-cli trusted -d request-vc did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 -a "dynamic 0000000000000000000000000000000000000001 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046f72646900000000000000000000000000000000000000000000000000000000"

// params[0]=sats
./bin/litentry-cli trusted -d request-vc did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 -a "dynamic 0000000000000000000000000000000000000001 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047361747300000000000000000000000000000000000000000000000000000000"

result:

~/repo/litentry-parachain/tee-worker$ ./bin/litentry-cli trusted -d request-vc did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 -a "dynamic 0000000000000000000000000000000000000001 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046f72646900000000000000000000000000000000000000000000000000000000"
>>> identity: Substrate(Address32)
>>> nonce: 1
>>> assertions: [Dynamic(0x0000000000000000000000000000000000000001, BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 111, 114, 100, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024))]
----Generated VC-----
{
   "@context":[
      "https://www.w3.org/2018/credentials/v1",
      "https://w3id.org/security/suites/ed25519-2020/v1"
   ],
   "id":"0xee00c047c3baedac39579c4e2c16aec6416b8ca704a9c3bfbd4d76e59a3bd390",
   "type":[
      "VerifiableCredential"
   ],
   "credentialSubject":{
      "id":"did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42",
      "description":"The amount of a particular token you are holding",
      "type":"Token Holding Amount",
      "assertionText":"Dynamic(0x0000000000000000000000000000000000000001, BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 111, 114, 100, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024))",
      "assertions":[
         {
            "and":[
               {
                  "src":"$token",
                  "op":"==",
                  "dst":"ordi"
               },
               {
                  "src":"$holding_amount",
                  "op":">=",
                  "dst":"0"
               },
               {
                  "src":"$holding_amount",
                  "op":"<",
                  "dst":"1"
               }
            ]
         }
      ],
      "values":[
         false
      ],
      "endpoint":"wss://rpc.rococo-parachain.litentry.io/"
   },
   "issuer":{
      "id":"did:litentry:substrate:0x8b3f21f9c1d9fb2350920597e9f0f3e20aa415a2cfac589e2d9d3efc84f6fc3b",
      "name":"Litentry TEE Worker",
      "mrenclave":"588cUwmkxSQKTDq5xDbiUzgwZAsU35pNzLAy1sECwaLv",
      "runtimeVersion":{
         "parachain":9181,
         "sidechain":107
      }
   },
   "issuanceDate":"2024-06-17T06:58:04.112585160+00:00",
   "parachainBlockNumber":109,
   "sidechainBlockNumber":208,
   "proof":{
      "created":"2024-06-17T06:58:04.114029743+00:00",
      "type":"Ed25519Signature2020",
      "proofPurpose":"assertionMethod",
      "proofValue":"e77773708b91fa4788a87ecaa3e035c2359f624657c3e6161aa5b3a2a56ae5f247af35ad231e7321ed8b64fc0276dfbc88363cf654ba1f9a7153f44de618ba04",
      "verificationMethod":"0x8b3f21f9c1d9fb2350920597e9f0f3e20aa415a2cfac589e2d9d3efc84f6fc3b"
   },
   "credentialSchema":{
      "id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/25-token-holding-amount/1-1-0.json",
      "type":"JsonSchemaValidator2018"
   }
}
|
~/repo/litentry-parachain/tee-worker$ ./bin/litentry-cli trusted -d request-vc did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 -a "dynamic 0000000000000000000000000000000000000001 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000047361747300000000000000000000000000000000000000000000000000000000"
>>> identity: Substrate(Address32)
>>> nonce: 1
>>> assertions: [Dynamic(0x0000000000000000000000000000000000000001, BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 115, 97, 116, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024))]
----Generated VC-----
{
   "@context":[
      "https://www.w3.org/2018/credentials/v1",
      "https://w3id.org/security/suites/ed25519-2020/v1"
   ],
   "id":"0x095fae74b17de446d068c028ebcd8fe4ae67a2bb24635ab938e2182081cb9047",
   "type":[
      "VerifiableCredential"
   ],
   "credentialSubject":{
      "id":"did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42",
      "description":"The amount of a particular token you are holding",
      "type":"Token Holding Amount",
      "assertionText":"Dynamic(0x0000000000000000000000000000000000000001, BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 115, 97, 116, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024))",
      "assertions":[
         {
            "and":[
               {
                  "src":"$token",
                  "op":"==",
                  "dst":"ordi"
               },
               {
                  "src":"$holding_amount",
                  "op":">=",
                  "dst":"0"
               },
               {
                  "src":"$holding_amount",
                  "op":"<",
                  "dst":"1"
               }
            ]
         }
      ],
      "values":[
         false
      ],
      "endpoint":"wss://rpc.rococo-parachain.litentry.io/"
   },
   "issuer":{
      "id":"did:litentry:substrate:0x8b3f21f9c1d9fb2350920597e9f0f3e20aa415a2cfac589e2d9d3efc84f6fc3b",
      "name":"Litentry TEE Worker",
      "mrenclave":"588cUwmkxSQKTDq5xDbiUzgwZAsU35pNzLAy1sECwaLv",
      "runtimeVersion":{
         "parachain":9181,
         "sidechain":107
      }
   },
   "issuanceDate":"2024-06-17T06:58:11.527279460+00:00",
   "parachainBlockNumber":110,
   "sidechainBlockNumber":209,
   "proof":{
      "created":"2024-06-17T06:58:11.527958923+00:00",
      "type":"Ed25519Signature2020",
      "proofPurpose":"assertionMethod",
      "proofValue":"688074d14df8399fca0b3be18c2f96ab3aa04d2f144d0128f3aff9a8c51d95e1837cbc885eeb418d1e79631a3f37058d07b8308f7b7edb80fc0cc119ffa86708",
      "verificationMethod":"0x8b3f21f9c1d9fb2350920597e9f0f3e20aa415a2cfac589e2d9d3efc84f6fc3b"
   },
   "credentialSchema":{
      "id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/25-token-holding-amount/1-1-0.json",
      "type":"JsonSchemaValidator2018"
   }
}

@higherordertech higherordertech merged commit 190401a into dev Jun 17, 2024
32 of 33 checks passed
@BillyWooo BillyWooo deleted the P-861-DA-extra-params branch June 18, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C0-breaking Breaking change that will cause existing client to break
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants