Skip to content

feat: cbor encoding of all referenced param & return types #397

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented Jul 4, 2025

Closes: #396

SectorContentChanged is a little odd to include here, but it's referenced as in the market methods and uses the miner types for the call, which makes sense, but you don't typically even see it. Maybe if you were decoding internal calls between actors, or were doing some testing of a smart contract that uses it.

The *uint64 ones are because we have some methods that use them, GetSectorSizeExported and GetDealSectorExported. We don't really need the nullability, however, but we declare them as pointers in methods.go so we'll just be complete here.

Copilot

This comment was marked as outdated.

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2025

Codecov Report

Attention: Patch coverage is 2.53456% with 1692 lines in your changes missing coverage. Please review.

Project coverage is 3.59%. Comparing base (3cfb1b4) to head (b7cbcb2).

Files with missing lines Patch % Lines
builtin/v13/miner/cbor_gen.go 0.00% 192 Missing ⚠️
builtin/v14/miner/cbor_gen.go 0.00% 192 Missing ⚠️
builtin/v15/miner/cbor_gen.go 0.00% 192 Missing ⚠️
builtin/v16/miner/cbor_gen.go 0.00% 192 Missing ⚠️
builtin/v17/miner/cbor_gen.go 0.00% 192 Missing ⚠️
builtin/v10/cron/cbor_gen.go 0.00% 68 Missing ⚠️
builtin/v11/cron/cbor_gen.go 0.00% 68 Missing ⚠️
builtin/v12/cron/cbor_gen.go 0.00% 68 Missing ⚠️
builtin/v13/cron/cbor_gen.go 0.00% 68 Missing ⚠️
builtin/v14/cron/cbor_gen.go 0.00% 68 Missing ⚠️
... and 16 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #397      +/-   ##
==========================================
- Coverage    3.60%    3.59%   -0.01%     
==========================================
  Files         733      734       +1     
  Lines      199998   201729    +1731     
==========================================
+ Hits         7212     7256      +44     
- Misses     190519   192199    +1680     
- Partials     2267     2274       +7     
Files with missing lines Coverage Δ
builtin/v13/miner/miner_types.go 0.00% <ø> (ø)
builtin/v14/miner/miner_types.go 0.00% <ø> (ø)
builtin/v15/miner/miner_types.go 0.00% <ø> (ø)
builtin/v16/miner/miner_types.go 0.00% <ø> (ø)
builtin/v17/miner/miner_types.go 0.00% <ø> (ø)
builtin/v10/gen/gen.go 0.00% <0.00%> (ø)
builtin/v11/gen/gen.go 0.00% <0.00%> (ø)
builtin/v12/gen/gen.go 0.00% <0.00%> (ø)
builtin/v8/gen/gen.go 0.00% <0.00%> (ø)
builtin/v9/gen/gen.go 0.00% <0.00%> (ø)
... and 21 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rvagg rvagg force-pushed the rvagg/serialise-all branch from 6b614a4 to f911c55 Compare July 4, 2025 11:12
@rvagg rvagg requested a review from Copilot July 4, 2025 11:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds CBOR serialization support for several method parameter and return types across the builtin actor versions, converts some miner result aliases into transparent structs for encoding, and introduces nullable uint64 helpers with tests.

  • Include cron.ConstructorParams in CBOR code generation for all referenced versions.
  • Replace SectorContentChanged* slice aliases with transparent structs and generate their CBOR methods.
  • Add marshalNullableUint64/unmarshalNullableUint64 helpers and unit tests in abi/.

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.

Show a summary per file
File Description
builtin/v{8–17}/gen/gen.go Added cron.ConstructorParams to the CBOR generation list for each version.
builtin/v{8–17}/cron/cbor_gen.go Generated MarshalCBOR/UnmarshalCBOR for cron.ConstructorParams.
builtin/v{14–17}/miner/miner_types.go Changed SectorContentChanged* aliases into transparent structs for CBOR.
builtin/v{14–17}/miner/cbor_gen.go Generated CBOR methods for the new SectorContentChanged* types.
abi/cbor_uint_types.go Introduced nullable uint64 marshal/unmarshal helpers.
abi/cbor_test.go Added tests covering nullable uint64 serialization edge cases.
Comments suppressed due to low confidence (2)

builtin/v17/miner/miner_types.go:472

  • Changing SectorContentChangedParams from a slice alias to a struct alters the public type and breaks backward compatibility. Consider layering a new struct alias or providing conversion helpers to preserve the original slice-based API.
type SectorContentChangedParams struct {

abi/cbor_uint_types.go:11

  • No unit tests cover marshalNullableUint64 and unmarshalNullableUint64 for both nil and non-nil cases. Add tests to ensure correct encoding of null vs. actual values and error paths.
func marshalNullableUint64(w io.Writer, v *uint64) error {

@rvagg
Copy link
Member Author

rvagg commented Jul 4, 2025

OK, this fails because the codegen for my simple transparent type does this:

func (t *PieceReturn) MarshalCBOR(w io.Writer) error {
	cw := cbg.NewCborWriter(w)

	// t.Accepted (bool) (bool)
	if err := cbg.WriteBool(w, t.Accepted); err != nil {
		return err
	}
	return nil
}

So that's a cbor-gen fix unfortunately.

@rvagg rvagg marked this pull request as draft July 4, 2025 11:19
@rvagg
Copy link
Member Author

rvagg commented Jul 4, 2025

I've added a tmp commit to get it to at least compile and not complain, that'll need to be undone with a proper gen though

rvagg added a commit to filecoin-project/lotus that referenced this pull request Jul 4, 2025
rvagg added a commit to filecoin-project/lotus that referenced this pull request Jul 4, 2025
rvagg added a commit to filecoin-project/lotus that referenced this pull request Jul 4, 2025
rvagg added a commit to filecoin-project/lotus that referenced this pull request Jul 4, 2025
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FilOz Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ⌨️ In Progress
Development

Successfully merging this pull request may close these issues.

Add cron params to codegen (🌽)
2 participants