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

fix(core): anchor proofs use txType instead of version - CDB-2074 #2565

Merged
merged 3 commits into from
Nov 25, 2022

Conversation

oed
Copy link
Member

@oed oed commented Nov 19, 2022

Having a version property doesn't make much sense given that we want to standardize IPLD timestamp proofs as a CAIP.

I suggest that we instead use txType and set it to f(bytes32) which represents any EVM function call that includes a bytes32 dag-cbor multihash. For "version 0" I suggest we use raw (and accept absence).

On CAS: ceramicnetwork/ceramic-anchor-service#821

@oed oed changed the title fix(core): anchor proofs use txType instead of version fix(core): anchor proofs use txType instead of version - CDB-2074 Nov 23, 2022
@linear
Copy link

linear bot commented Nov 23, 2022

Copy link
Contributor

@stbrody stbrody left a comment

Choose a reason for hiding this comment

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

I suggest that we instead use txType and set it to f(bytes32) which represents any EVM function call that includes a bytes32 dag-cbor multihash

Do we want to be more specific in the type that saying it accepts any EVM function call that accepts a bytes32? Should we make clear that it must be our smart contract's anchor function? Or at least that the bytes32 must be a dag-cbor multihash?

@@ -72,20 +70,20 @@ const getCidFromV0Transaction = (txResponse: TransactionResponse): CID => {
}

const getCidFromV1Transaction = (txResponse: TransactionResponse): CID => {
const decodedArgs = iface.decodeFunctionData('anchorDagCbor', txResponse.data)
Copy link
Contributor

Choose a reason for hiding this comment

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

so I don't really know what this is doing, but it looks to me like using a function designed to decode the data here would be less brittle than just directly counting bytes. Any reason for changing this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can change it back. I think this is safe though since it's unlikely that EVM will change the number of bytes used for the function signature. If it did it would also break the tool we are using here.

return CID.create(1, DAG_CBOR_CODE, multihash)
}

/**
* Parses the transaction data to recover the CID.
* @param version version of the anchor proof. Version 1 anchor proofs are created using the official anchoring smart contract and must be parsed accordingly
* @param txType transaction type of the anchor proof. Currently support `raw` and `dagCbor(bytes32)`
Copy link
Contributor

Choose a reason for hiding this comment

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

is it dagCbor(bytes32) or f(bytes32)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, this should say f(bytes32).

@@ -45,10 +44,9 @@ const BASE_CHAIN_ID = 'eip155'
const MAX_PROVIDERS_COUNT = 100
const TRANSACTION_CACHE_SIZE = 50
const BLOCK_CACHE_SIZE = 50
const V0_PROOF_TYPE = 'raw'
const V1_PROOF_TYPE = 'f(bytes32)'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you comment what each of these strings represent/mean? f(bytes32) is pretty opaque to me (I can guess it means a function than takes 32 bytes as an input, but still not really clear what it means for that to be the "proof type" or why we chose that string)

Copy link
Member Author

Choose a reason for hiding this comment

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

We should add a comment here when we've created the eip155 namespace.

Added a follow up story here: https://linear.app/3boxlabs/issue/RES-812/add-reference-to-caip-168-namespace-registered-values

@stbrody stbrody requested a review from ukstv November 23, 2022 15:10
@oed
Copy link
Member Author

oed commented Nov 23, 2022

Do we want to be more specific in the type that saying it accepts any EVM function call that accepts a bytes32?

I don't think we need to.

Should we make clear that it must be our smart contract's anchor function?

Ideally not. Would be good to keep this general as it might be used by others who use the CAIP-168 spec. The plan is to register both raw and f(bytes32) in the eip155 namespace.

Or at least that the bytes32 must be a dag-cbor multihash?

We will register f(bytes32) to mean a multihash of a dag-cbor CID when we add it to the eip155 namespace

Copy link
Contributor

@ukstv ukstv left a comment

Choose a reason for hiding this comment

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

That's slightly more indirect, than just version number, and IMO, it is all right.

@oed oed merged commit bed5161 into develop Nov 25, 2022
@oed oed deleted the fix/tx-type branch November 25, 2022 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants