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

v3: Change SDK::send's params to take new type IpldBlock #1152

Merged
merged 1 commit into from
Dec 17, 2022

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek commented Nov 27, 2022

Towards #987, but doesn't close it.

Introduces a new IpldBlock type that can support various codecs (currently DAG_CBOR and IPLD_RAW), and switches the SDK::send method to use Option<IpldBlock> for params.

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2022

Codecov Report

Merging #1152 (105786f) into master (dd79a13) will decrease coverage by 17.40%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1152       +/-   ##
===========================================
- Coverage   43.10%   25.69%   -17.41%     
===========================================
  Files         128       96       -32     
  Lines       13110     7767     -5343     
===========================================
- Hits         5651     1996     -3655     
+ Misses       7459     5771     -1688     
Impacted Files Coverage Δ
ipld/encoding/src/cbor.rs 0.00% <ø> (-39.35%) ⬇️
ipld/encoding/src/errors.rs 0.00% <0.00%> (-51.43%) ⬇️
ipld/encoding/src/ipld_block.rs 0.00% <0.00%> (ø)
ipld/encoding/src/lib.rs 46.15% <ø> (+4.21%) ⬆️
ipld/encoding/src/raw.rs 0.00% <0.00%> (ø)
shared/src/bigint/biguint_ser.rs 0.00% <0.00%> (-85.72%) ⬇️
ipld/encoding/src/vec.rs 0.00% <0.00%> (-84.56%) ⬇️
shared/src/address/network.rs 0.00% <0.00%> (-80.36%) ⬇️
shared/src/piece/mod.rs 0.00% <0.00%> (-73.98%) ⬇️
shared/src/address/protocol.rs 0.00% <0.00%> (-72.73%) ⬇️
... and 122 more

Comment on lines 20 to 22
// IPLD_RAW => BytesDeserializer::new(self.data.as_slice())
// .deser()
// .map_err(Into::into),
Copy link
Member

Choose a reason for hiding this comment

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

Does this not work? (any reason not to just enable it?)

use fvm_ipld_encoding::DAG_CBOR;
use {serde, serde_ipld_dagcbor};

// TODO: Slapped the Serialize derivations on for some actors testing, not clear to me it should stay
Copy link
Member

Choose a reason for hiding this comment

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

Yep, they shouldn't. Otherwise, we'll serialize twice.

@arajasek arajasek force-pushed the asr/ipld-block branch 2 times, most recently from efeb3f4 to bfab2e4 Compare December 1, 2022 16:52
@arajasek arajasek marked this pull request as ready for review December 1, 2022 16:52
@arajasek arajasek requested review from anorth, raulk and vyzo December 1, 2022 16:53
@arajasek arajasek force-pushed the asr/ipld-block branch 3 times, most recently from 105786f to a31c967 Compare December 1, 2022 18:17
@arajasek arajasek force-pushed the asr/ipld-block branch 2 times, most recently from b2ce904 to ecdb0ec Compare December 5, 2022 18:47
@arajasek arajasek changed the title Add type IpldBlock to support multiple codecs v3: Change SDK::send's params to take new type IpldBlock Dec 5, 2022
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

this looks useful.

@arajasek arajasek force-pushed the asr/ipld-block branch 4 times, most recently from cf4594e to 8dcfe70 Compare December 5, 2022 20:46
@@ -135,7 +139,10 @@ fn invoke_method(blk: u32, method: u64) -> u32 {
let output = sdk::send::send(
&Address::new_id(sdk::message::receiver()),
4,
RawBytes::new("input".into()),
Some(IpldBlock {
codec: DAG_CBOR,
Copy link
Member

Choose a reason for hiding this comment

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

nit: now that we can, consider using DAG_RAW? (if it works)

@arajasek arajasek enabled auto-merge (squash) December 12, 2022 16:14
@arajasek arajasek disabled auto-merge December 12, 2022 16:27
IpldBlock supports multiple codecs, including IPLD_RAW.

Serializing byte vectors will correctly serialize anything that serializes to "raw bytes".
However, it _won't_ serialize "byte lists", so `Vec<u8>` and `[u8]`
won't work. But that shouldn't be an issue in practice.

Users _should_ serialize to/from `ByteBuf`.
@arajasek arajasek merged commit 4722695 into master Dec 17, 2022
@arajasek arajasek deleted the asr/ipld-block branch December 17, 2022 20:47
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.

5 participants