Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

create type for deal label #320

Merged
merged 1 commit into from
Feb 28, 2023
Merged

create type for deal label #320

merged 1 commit into from
Feb 28, 2023

Conversation

emmanuelm41
Copy link
Member

@emmanuelm41 emmanuelm41 commented Feb 28, 2023

closes #318

馃敆 zboto Link

@github-actions
Copy link

Gas results 馃殌馃摑

Account actor

Function Gas
authenticate_message 25095220
universal_receiver_hook 4818537

Miner actor

Function Gas
change_owner_address 7430383
get_beneficiary 9798716
change_beneficiary 8729771
get_owner 7407589
get_available_balance 5880994
get_vesting_funds 6084626
repay_debt 6324623
confirm_change_worker_address 6233761
get_peer_id 6518890
get_multiaddresses 7043208
change_worker_address 8915501
is_controlling_address 6505027
get_sector_size 5795901
change_multiaddresses 8029563
change_peer_id 7605687
withdraw_balance 8443969

Datacap actor

Function Gas
name 5701812
symbol 5455248
total_supply 7468005
balance 6690223
allowance 7827514
transfer 17420495
transfer_from 25139141
burn 10913309
burn_from 18070392
allowance 11115365
increase_allowance 13830421
decrease_allowance 13822454
revoke_allowance 12378191

Init actor

Function Gas
exec 19751546
exec4 6770545

Market actor

Function Gas
publish_storage_deals 49710493
add_balance 7643461
withdraw_balance 10425706
get_balance 11825907
get_deal_data_commitment 10896585
get_deal_client 6183292
get_deal_provider 6179796
get_deal_label 10994056
get_deal_term 6812205
get_deal_total_price 8266412
get_deal_client_collateral 8081663
get_deal_provider_collateral 8077183
get_deal_verified 6099902
get_deal_activation 6856649

Power actor

Function Gas
miner_count 4791904
network_raw_power 5232334
miner_raw_power 6741204
miner_consensus_count 4806008

Precompiles actor

Function Gas
resolve_address 2512401
lookup_delegated_address (empty response) 2335464
lookup_delegated_address (address found) 2422468
resolve_eth_address 2445887

Send actor

Function Gas
send (actor id) 3277150
send (address) 3591454

Verifreg actor

Function Gas
add_verified_client 13286460
get_claims 10046317
extend_claim_term 11444121
remove_expired_allocations 12982513
remove_expired_claims 11444121

@emmanuelm41 emmanuelm41 merged commit 93e91bf into master Feb 28, 2023
@emmanuelm41 emmanuelm41 deleted the fix/market-label-deal branch February 28, 2023 14:03
Copy link
Contributor

@raulk raulk left a comment

Choose a reason for hiding this comment

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

This LGTM besides the comments.

@@ -130,6 +130,10 @@ library MarketCBOR {
buf.startFixedArray(uint64(params.deals.length));

for (uint64 i = 0; i < params.deals.length; i++) {
bool isLabelStr = bytes(params.deals[i].proposal.label.dataStr).length > 0;
bool isLabelBts = params.deals[i].proposal.label.dataBts.length > 0;
require((!isLabelStr && isLabelBts) || (!isLabelBts && isLabelStr), "deal label must be either string or bytes");
Copy link
Contributor

Choose a reason for hiding this comment

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

Not super deep into this code, but can't this be simplified?

Suggested change
require((!isLabelStr && isLabelBts) || (!isLabelBts && isLabelStr), "deal label must be either string or bytes");
require(!(isLabelStr && isLabelBts), "deal label must be either string or bytes");

Also worth noting that this will default to serializing empty bytes if none is set, which I think is fine, but please document that behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes Raul, you are right! good catch

@@ -64,5 +64,11 @@ library CommonTypes {
bytes data;
}

/// @param dataBytes deal proposal label in bytes format (it can be utf8 string or arbitray bytes string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we strengthen the documentation to indicate that this is actually an enum type and it's expect to be either or? Also check typos.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add that in the inline docs

longfeiWan9 pushed a commit to longfeiWan9/filecoin-solidity that referenced this pull request Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deal Proposal struct label field type needs to mirror whats in the protocol
2 participants