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

Contracts that use libraries are not sized accurately #1

Closed
cgewecke opened this issue Mar 4, 2021 · 3 comments
Closed

Contracts that use libraries are not sized accurately #1

cgewecke opened this issue Mar 4, 2021 · 3 comments

Comments

@cgewecke
Copy link

cgewecke commented Mar 4, 2021

Hi @ItsNickBarry! Love this plugin

When sizing a contract whose bytecode includes library address placeholders, e.g. __$....$__, it seems like the size measurement is incorrect - it only returns size up to the first placeholder entry.

A repro based on how length is measured here is:

const a = "aaaa__$aaaa$__aaaa";
const b = "bbbbbbbbbbbbbbbbbb";

a_bufferLength = Buffer.from(a, 'hex').length;  // Issue w/ non-hex chars?
b_bufferLength = Buffer.from(b, 'hex').length;

a_stringLength = a.length;
b_stringLength = b.length;

console.log(`a_bufferLength: ${a_bufferLength}`);
console.log(`b_bufferLength: ${b_bufferLength}`);
console.log(`a_stringLength: ${a_stringLength}`);
console.log(`b_stringLength: ${b_stringLength}`);

> a_bufferLength: 2  // Short
> b_bufferLength: 9  // OK
> a_stringLength: 18
> b_stringLength: 18
@ItsNickBarry
Copy link
Owner

ItsNickBarry commented Mar 4, 2021

Does #2 correctly resolve this? I'm not especially familiar with libraries. Can confirm that the non-hex characters were causing problems with the buffer length.

@cgewecke
Copy link
Author

cgewecke commented Mar 4, 2021

Yeah! Looks good. I swapped that change into my local node_modules copy and got what I was expecting.

deployedBytecode.length --> 42842 // String
size --> 21421 // Buffer

@ItsNickBarry
Copy link
Owner

Fixed in version 2.0.3.

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

No branches or pull requests

2 participants