Skip to content

Fix cbindgen warnings with cbindgen:ignore annotations and native feature define#4466

Open
joshuacolvin0 wants to merge 2 commits intomasterfrom
cbindgen-fix
Open

Fix cbindgen warnings with cbindgen:ignore annotations and native feature define#4466
joshuacolvin0 wants to merge 2 commits intomasterfrom
cbindgen-fix

Conversation

@joshuacolvin0
Copy link
Member

@joshuacolvin0 joshuacolvin0 commented Mar 5, 2026

Closes NIT-4532

Add /// cbindgen:ignore to Gas, Ink, and prover constants that cbindgen
cannot translate to C (newtype wrappers, method chains, string literals,
unsupported expressions). Add [defines] section mapping the native feature
to STYLUS_NATIVE for conditional compilation guards in the generated header.

Reduces cbindgen warnings from 52 to 3 (remaining are generic type
mangling issues that cannot be resolved with annotations).

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

…ture define

Add /// cbindgen:ignore to Gas, Ink, and prover constants that cbindgen
cannot translate to C (newtype wrappers, method chains, string literals,
unsupported expressions). Add [defines] section mapping the native feature
to STYLUS_NATIVE for conditional compilation guards in the generated header.

Reduces cbindgen warnings from 52 to 3 (remaining are generic type
mangling issues that cannot be resolved with annotations).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.74%. Comparing base (b9b3864) to head (ce38774).
⚠️ Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4466      +/-   ##
==========================================
+ Coverage   32.72%   32.74%   +0.02%     
==========================================
  Files         493      493              
  Lines       58290    58294       +4     
==========================================
+ Hits        19076    19090      +14     
+ Misses      35868    35860       -8     
+ Partials     3346     3344       -2     

Comment on lines +9 to +10
[defines]
"feature = native" = "STYLUS_NATIVE"
Copy link
Member

Choose a reason for hiding this comment

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

this seems to cause compilation failure:

  Error: validator/server_arb/machine.go:363:12: could not determine what C.arbitrator_add_inbox_message refers to
  Error: validator/server_arb/machine.go:454:2: could not determine what C.arbitrator_add_user_wasm refers to
  Error: validator/server_arb/machine.go:138:32: could not determine what C.arbitrator_clone_machine refers to
  Error: validator/server_arb/machine.go:344:12: could not determine what C.arbitrator_deserialize_and_replace_state refers to
  Error: validator/server_arb/machine.go:88:3: could not determine what C.arbitrator_free_machine refers to
  Error: validator/server_arb/machine.go:308:2: could not determine what C.arbitrator_gen_proof refers to
  Error: validator/server_arb/machine.go:181:16: could not determine what C.arbitrator_get_num_steps refers to

at least without it, make lint succeeds

pub mod storage;
pub mod user;

/// cbindgen:ignore
Copy link
Member

Choose a reason for hiding this comment

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

from what I see, many objects don't require this annotation - cbindgen handles well const values (it fails with const expressions though); therefore I think it's worth considering to put these annotations only where they are actually needed; for example, they are not useful anywhere in this module

Copy link
Member Author

@joshuacolvin0 joshuacolvin0 Mar 5, 2026

Choose a reason for hiding this comment

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

They reduce the warnings, but if we don't care about warnings, we can remove them

You are correct, many were not needed

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

❌ 9 Tests Failed:

Tests completed Failed Passed Skipped
4288 9 4279 0
View the top 3 failed tests by shortest run time
TestRedisProduceComplex
Stack Traces | -0.000s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
	/opt/hostedtoolcache/go/1.25.7/x64/src/testing/testing.go:1205 +0x59
github.com/offchainlabs/nitro/pubsub.consume.func1({0x16f8fd8, 0xc000390460})
	/home/runner/work/nitro/nitro/pubsub/pubsub_test.go:203 +0x5d2
github.com/offchainlabs/nitro/util/stopwaiter.(*StopWaiterSafe).LaunchThreadSafe.func1()
	/home/runner/work/nitro/nitro/util/stopwaiter/stopwaiter.go:163 +0x38
created by github.com/offchainlabs/nitro/util/stopwaiter.(*StopWaiterSafe).LaunchThreadSafe in goroutine 51
	/home/runner/work/nitro/nitro/util/stopwaiter/stopwaiter.go:162 +0x125
panic: Fail in goroutine after TestRedisProduceComplex/one_producer,_all_consumers_are_active has completed

goroutine 67 [running]:
testing.(*common).Fail(0xc000323c00)
	/opt/hostedtoolcache/go/1.25.7/x64/src/testing/testing.go:960 +0xca
testing.(*common).Errorf(0xc000323c00, {0x147607c?, 0x16efdc0?}, {0xc000611f98?, 0xc00039b008?, 0xf?})
	/opt/hostedtoolcache/go/1.25.7/x64/src/testing/testing.go:1205 +0x59
github.com/offchainlabs/nitro/pubsub.consume.func1({0x16f8fd8, 0xc000390d70})
	/home/runner/work/nitro/nitro/pubsub/pubsub_test.go:203 +0x5d2
github.com/offchainlabs/nitro/util/stopwaiter.(*StopWaiterSafe).LaunchThreadSafe.func1()
	/home/runner/work/nitro/nitro/util/stopwaiter/stopwaiter.go:163 +0x38
created by github.com/offchainlabs/nitro/util/stopwaiter.(*StopWaiterSafe).LaunchThreadSafe in goroutine 51
	/home/runner/work/nitro/nitro/util/stopwaiter/stopwaiter.go:162 +0x125
TestRedisProduceComplex/two_producers,_all_consumers_are_active
Stack Traces | -0.000s run time
=== RUN   TestRedisProduceComplex/two_producers,_all_consumers_are_active
TestRedisProduceComplex/one_producer,_all_consumers_are_active
Stack Traces | 1.280s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: setting result                 �[36mcid�[0m=2bf53528-ad82-414c-9a63-cdaa1f4768b6 �[36mmsgIdInStream�[0m=1772745778444-6  �[36mresultKeyInRedis�[0m=result-key:stream:47725356-15d2-4862-83fd-806f7580b345.1772745778444-6
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xack                           �[36mcid�[0m=a8206a49-4809-4cdf-bdc9-0cbd83062b73 �[36mmessageId�[0m=1772745778444-8
�[36mDEBUG�[0m[03-05|21:22:59.573] consumer: xack                           �[36mcid�[0m=3fe38b76-2748-4313-b047-94fc999f475b �[36mmessageId�[0m=1772745778444-1
�[36mDEBUG�[0m[03-05|21:22:59.573] consumer: xdel                           �[36mcid�[0m=1b71448b-2c6a-47a3-8167-5f06d1737848 �[36mmessageId�[0m=1772745778444-5
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=e745d60e-acf1-4de1-8a5a-c35545a151ba �[36mmessageId�[0m=1772745778444-2
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xack                           �[36mcid�[0m=d9d923d8-d135-4e4a-97e3-ad7487f48841 �[36mmessageId�[0m=1772745778444-7
�[36mDEBUG�[0m[03-05|21:22:59.574] trimming                                 �[36mxTrimMinID�[0m=1772745778444-0 �[36mtrimmed�[0m=1 �[36mtrim-err�[0m=&lt;nil&gt;
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xack                           �[36mcid�[0m=2bf53528-ad82-414c-9a63-cdaa1f4768b6 �[36mmessageId�[0m=1772745778444-6
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=caebd994-3f36-43ed-9dad-8bdf3576196f �[36mmessageId�[0m=1772745778444-4
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=3fe38b76-2748-4313-b047-94fc999f475b �[36mmessageId�[0m=1772745778444-1
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=2bf53528-ad82-414c-9a63-cdaa1f4768b6 �[36mmessageId�[0m=1772745778444-6
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=e9c178a1-8f0d-4b13-a31b-00e3809c9a18 �[36mmessageId�[0m=1772745778444-0
�[36mDEBUG�[0m[03-05|21:22:59.574] consumer: xdel                           �[36mcid�[0m=a8206a49-4809-4cdf-bdc9-0cbd83062b73 �[36mmessageId�[0m=1772745778444-8
�[36mDEBUG�[0m[03-05|21:22:59.577] consumer: xdel                           �[36mcid�[0m=d9d923d8-d135-4e4a-97e3-ad7487f48841 �[36mmessageId�[0m=1772745778444-7
�[36mDEBUG�[0m[03-05|21:22:59.642] checkResponses                           �[36mresponded�[0m=73 �[36merrored�[0m=0 �[36mchecked�[0m=75
�[36mDEBUG�[0m[03-05|21:22:59.647] redis producer: check responses starting
�[36mDEBUG�[0m[03-05|21:22:59.650] checkResponses                           �[36mresponded�[0m=2  �[36merrored�[0m=0 �[36mchecked�[0m=2
    pubsub_test.go:203: Consume() unexpected error: reading message for consumer: "1b71448b-2c6a-47a3-8167-5f06d1737848": NOGROUP No such key 'stream:47725356-15d2-4862-83fd-806f7580b345' or consumer group 'stream:47725356-15d2-4862-83fd-806f7580b345' in XREADGROUP with GROUP option
�[31mERROR�[0m[03-05|21:22:59.651] Error from XpendingExt in getting PEL for auto claim �[31merr�[0m="context canceled" �[31mpendingLen�[0m=0
--- FAIL: TestRedisProduceComplex/one_producer,_all_consumers_are_active (1.28s)

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Remove the [defines] section from cbindgen.toml that wrapped
arbitrator_* functions in #ifdef STYLUS_NATIVE guards, breaking CGo.

Remove unnecessary cbindgen:ignore annotations on non-pub constants
and simple newtype constructors. Add annotations to evm/mod.rs
constants that alias other Gas constants (e.g. TLOAD_GAS =
WARM_SLOAD_GAS), which produced dangling #define references in the
generated C header.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants