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:add Mary protocol parameters support #589

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

verbotenj
Copy link
Contributor

@verbotenj verbotenj commented Apr 18, 2024

era = Mary, slot = 39916796, block_no = 6236059, id = e72579ff89dc9ed325b723a33624b596c08141c7bd573ecfff56a1f7229e4d09
era = Alonzo, slot = 39916975, block_no = 6236060, id = 8959c0323b94cc670afe44222ab8b4e72cfcad3b5ab665f334bbe642dc6e9ef4

Closes #326

@verbotenj verbotenj force-pushed the feat/add-protocol-param-support branch from 997486d to 2b3a091 Compare April 21, 2024 21:39
@verbotenj verbotenj marked this pull request as ready for review April 21, 2024 21:41
type Nonce struct {
cbor.StructAsArray
Type uint `cbor:"0,keyasint"`
Value any `cbor:"1,keyasint,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these cbor tags. They don't do anything when using cbor.StructAsArray. The keyasint and omitempty tags only work when dealing with a map (this is a list).

type Nonce struct {
cbor.StructAsArray
Type uint `cbor:"0,keyasint"`
Value any `cbor:"1,keyasint,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The nonce value is bytes .size 32 according to the CDDL, so we should use [32]byte instead of any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I set to [32]byte, it cannot unmarshal positive integer into Go struct field struct { StructAsArray cbor.StructAsArray; Type uint; Value [32]uint8 }.Value of type [32]uint8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then I tried to use temp struct

		tmp := struct {
			cbor.StructAsArray
			Type  uint
			Value []byte
		}{}

And got
cbor: cannot unmarshal positive integer into Go struct field struct { StructAsArray cbor.StructAsArray; Type uint; Value []uint8 }.Value of type []uint8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried also

		tmp := struct {
			cbor.StructAsArray
			Type  uint
			Value []uint8
		}{}

I am not sure what does error want to tell me

{
name: "UnsupportedNonceType",
data: []byte{0x83, 0x00, 0x01, 0x02},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't actually fail. Your unmarshal function is checking the first value in the list (0 in this case), which is a supported value. Instead I'd use something like 8102 ([2]), which will cause an error.

@verbotenj verbotenj force-pushed the feat/add-protocol-param-support branch 5 times, most recently from 04b9cf6 to f6dc9e2 Compare April 21, 2024 22:53
Signed-off-by: Ales Verbic <verbotenj@blinklabs.io>
@verbotenj verbotenj force-pushed the feat/add-protocol-param-support branch from f6dc9e2 to 5a5d5d2 Compare April 22, 2024 13:32
@verbotenj verbotenj merged commit 34e77e7 into main Apr 22, 2024
8 checks passed
@verbotenj verbotenj deleted the feat/add-protocol-param-support branch April 22, 2024 13:55
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.

Mary protocol params support
2 participants