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

RLP encoding and decoding generator for simple structures #13341

Merged
merged 24 commits into from
Jan 23, 2025
Merged

Conversation

racytech
Copy link
Contributor

@racytech racytech commented Jan 8, 2025

No description provided.

@racytech racytech requested a review from yperbasis January 8, 2025 03:25
go.sum Show resolved Hide resolved
core/types/block.go Outdated Show resolved Hide resolved
}

func TestTestingStruct(t *testing.T) {
// tr := NewTRand()
Copy link
Member

Choose a reason for hiding this comment

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

Why is it commented out?

Copy link
Contributor Author

@racytech racytech Jan 10, 2025

Choose a reason for hiding this comment

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

Currently there are no EncodeRLP and DecodeRLP methods for TestingStruct, so the program wont compile due to the errors. Methods have to be generated and then this can be uncommented and tested. But in general, I suggest not to merge this to the main, since this required only for generator testing. Let me make the "merge-ready" version after I demonstrate and explain how does this work in the next upcoming call

@yperbasis yperbasis mentioned this pull request Jan 10, 2025
@racytech racytech marked this pull request as ready for review January 17, 2025 10:16
_ = addToImports(named)
}
// size
fmt.Fprintf(b1, " size += rlp.BigIntLenExcludingHead(&obj.%s) + 1\n", fieldName)
Copy link
Member

Choose a reason for hiding this comment

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

+1 only works if the number of significant bytes in the bigInt is smaller than 56, which theoretically might be not the case, though practically our bigInts are no longer than 32 bytes.

Copy link
Contributor Author

@racytech racytech Jan 20, 2025

Choose a reason for hiding this comment

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

I suggest adding extra check in BigIntLenExcludingHead function

if bitLen >= 56*8 { return libcommon.BitLenToByteLen(bitLen) - 1 } // so the caller can add +1 without hesitation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's actually not going to work

Copy link
Member

@yperbasis yperbasis Jan 20, 2025

Choose a reason for hiding this comment

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

OK, it's not a big deal and we can leave this as is since our bigInts are no longer than 32 bytes in practice.

go.mod Outdated
@@ -282,7 +282,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.26.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

up to v0.29.0 plz

return nil
}

func ByteSliceSlicePtrSize(bb []*[]byte) int {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? To my mind it doesn't make sense to have pointer to a slice since slices have reference semantics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, should be removed

@@ -0,0 +1,734 @@
// Copyright 2023 The Erigon Authors
Copy link
Member

Choose a reason for hiding this comment

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

Should be 2025

@racytech
Copy link
Contributor Author

racytech commented Jan 22, 2025

Seems like I don't have a rights for https://erigon3-v1-snapshots-mainnet... so the manifest check is failing

@yperbasis
Copy link
Member

Seems like I don't have a rights for https://erigon3-v1-snapshots-mainnet... so the manifest check is failing

The manifest check is flaky and unrelated to your changes, so can be ignored.

@racytech racytech merged commit 6c2b596 into main Jan 23, 2025
13 of 14 checks passed
@racytech racytech deleted the rlp_gen branch January 23, 2025 14:31
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.

3 participants