EOSIO / spec-repo

EOSIO Specifications Repository
MIT License
40 stars 8 forks source link

Sync call return size #6

Open b1bart opened 5 years ago

b1bart commented 5 years ago

Concern

In the definitions for the caller there seems to be no way to read the actual resulting buffer size or restrict it. It may not be necessary to restrict it but, allowing for a variable length return with some ability to validate seems valuable:

https://github.com/EOSIO/eep-proposal-staging/blob/de46cb9396217b3d013ec81fe19cc68f91d9747a/eep-draft_synchronous_calls.md#L67-L70

My assumption is this will transfer the result to the buffer pointed to which has the size indicated. Should it also return a size_t that indicates how much of the buffer it wrote to or would have written to?

Should this be something the caller can limit when making a call?

arhag commented 5 years ago

there seems to be no way to read the actual resulting buffer size

That is returned by the call_sync_readonly function.

Should this be something the caller can limit when making a call?

Good question. The specification doesn't say what happens if the value of result_size is different than the value returned by call_sync_readonly. I would assume that it would make sense to ignore the extra space if it is larger and to restrict the amount of the buffer copied if it is smaller.

b1bart commented 5 years ago

yep on second read I caught that the call itself returns the size of the return value. I'm okay with that.

I guess I will leave this open to invite discussion on the limit.