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

Bugfix/abi encoding #1609

Merged
merged 4 commits into from
Apr 30, 2024
Merged

Bugfix/abi encoding #1609

merged 4 commits into from
Apr 30, 2024

Conversation

adamgall
Copy link
Member

@adamgall adamgall commented Apr 26, 2024

i think i found

  • 1 actual bug
  • 2 instances where the code is misleading

in various places where we do ABI encoding

Copy link

netlify bot commented Apr 26, 2024

Deploy Preview for fractal-dev ready!

Name Link
🔨 Latest commit 667bb65
🔍 Latest deploy log https://app.netlify.com/sites/fractal-dev/deploys/662c59fde9bd9a0008c06ecb
😎 Deploy Preview https://deploy-preview-1609.app.dev.fractalframework.xyz
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -25,7 +25,6 @@ import { generateContractByteCodeLinear, generateSalt } from './helpers/utils';

export class AzoriusTxBuilder extends BaseTxBuilder {
private readonly safeContract: GnosisSafeL2;
private readonly predictedSafeAddress: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused, removing.

@@ -54,7 +53,6 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
azoriusContracts: AzoriusContracts,
daoData: AzoriusERC20DAO | AzoriusERC721DAO,
safeContract: GnosisSafeL2,
predictedSafeAddress: string,
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused, removing.

@@ -68,7 +66,6 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
);

this.safeContract = safeContract;
this.predictedSafeAddress = predictedSafeAddress;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused, removing.

@@ -130,7 +130,6 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.azoriusContracts!,
this.daoData as AzoriusERC20DAO,
this.safeContract!,
this.predictedSafeAddress!,
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused, removing.

Comment on lines 349 to 351
['uint32', 'address', 'address', 'address', 'uint256'],
[
0, // deadlineBlock. do we capture this in the UI?
Copy link
Member Author

@adamgall adamgall Apr 26, 2024

Choose a reason for hiding this comment

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

This seems like an actual bug. The contract is expecting a uint32 before the rest of those parameters, and we weren't sending one in. Is this code path just rarely (ever) used in the app? I need to do some manual testing still.

Copy link
Member Author

@adamgall adamgall Apr 26, 2024

Choose a reason for hiding this comment

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

Yeah, sure enough this (original code) is BROKEN. Can't execute a proposal in which we're creating a subdao with a token claim for parent holders.

Copy link
Member Author

@adamgall adamgall Apr 26, 2024

Choose a reason for hiding this comment

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

And I AM able to execute the same kind of "parent holder token claim" proposal with my changes here in place. Nice.

@@ -217,7 +217,7 @@ export class FreezeGuardTxBuilder extends BaseTxBuilder {
'setUp',
[
ethers.utils.defaultAbiCoder.encode(
['uint256', 'uint256', 'address', 'address', 'address'],
['uint32', 'uint32', 'address', 'address', 'address'],
Copy link
Member Author

@adamgall adamgall Apr 26, 2024

Choose a reason for hiding this comment

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

The contract is expecting uint32s here, not uint256s.

Does this currently work as expected? I bet so, because we have tested freeze guard things before.

Will it be a problem to change this? Hope not.

subDaoData.timelockPeriod and subDaoData.executionPeriod are both typed as bigint though, which also "seems wrong" to me, because those things are uint32s on the contract. They don't need to be bigints, they can just be numbers. Updating those types makes this PR much hairier though.

I need to do some manual testing to make sure this change still works as intended, just like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did manual testing, this works as expected.

this.freezeGuardCallData = AzoriusFreezeGuard__factory.createInterface().encodeFunctionData(
'setUp',
[
ethers.utils.defaultAbiCoder.encode(
['address', 'address', 'address', 'address', 'uint256'],
['address', 'address'],
Copy link
Member Author

@adamgall adamgall Apr 26, 2024

Choose a reason for hiding this comment

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

We were straight up "encoding too much", here. The contract only expects two addresses. So, slimmed it down.

I bet this still works currently because the smart contract probably just discards everything after the first two address parameters.

Need to do some manual testing on this too of course.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did manual testing, this works as expected.

@adamgall adamgall self-assigned this Apr 29, 2024
@adamgall adamgall marked this pull request as ready for review April 29, 2024 15:53
@adamgall adamgall merged commit 1985843 into develop Apr 30, 2024
7 checks passed
@adamgall adamgall deleted the bugfix/abi-encoding branch April 30, 2024 15:05
@adamgall adamgall mentioned this pull request May 15, 2024
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