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

Fix multi-contrib nodes setting contract as operator of node #92

Conversation

Doy-lee
Copy link
Collaborator

@Doy-lee Doy-lee commented Oct 16, 2024

In my integration tests curiously multi-contributor contracts were failing until I realised that we were using msg.sender as the operator which is incorrect in the multi-contributor flow.

When you have a multi-contributor contract, that calls addBLSPublicKey on the rewards contract on the operator's behalf. This means that msg.sender is set to the multi-contribution contract. Then, in addBLSPublicKey we'd use the msg.sender to validateProofOfPossession but also emit a NewServiceNodeV2 log with the contract address.

This is incorrect and would prevent the operator from being able to exit the node. It'd also fail checks in core where it expects the 1st contributor to be the operator. The fix here is to correctly use msg.sender for transferring the stake and the 1st contributor as the operator for the SN metadata.

@Doy-lee Doy-lee requested a review from darcys22 October 16, 2024 06:23
sn.operator = contributors[0].staker.addr;
for (uint256 i = 0; i < contributors.length; i++)
sn.operator = operator;
for (uint256 i = 0; i < contributors.length; ) {
Copy link
Member

@jagerman jagerman Oct 16, 2024

Choose a reason for hiding this comment

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

Why did the i++ get dropped? (I don't see how this isn't an infinite loop without it)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see, I think this was a merge conflict with the ongoing audit response branch (which drops the i++ but has an unchecked { i += 1; } in the body).

Copy link
Member

Choose a reason for hiding this comment

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

I've pushed a fix.

sn.contributors.push(contributors[i]);
unchecked { i += 1 };
Copy link
Collaborator

Choose a reason for hiding this comment

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

unchecked { i++; }

@Doy-lee Doy-lee force-pushed the doyle-fix-multi-contrib-attributing-wrong-operator branch from c7a7c11 to 7a24a9e Compare October 16, 2024 23:29
@Doy-lee
Copy link
Collaborator Author

Doy-lee commented Oct 17, 2024

Thanks, have squashed the bugs back to the base commit (and fixed the syntax error in the unchecked section). Added an additional commit to fix the C++ tests since we got it working anyway, was a small fix.

@Doy-lee Doy-lee merged commit 1cabda5 into oxen-io:master Oct 17, 2024
2 checks passed
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.

3 participants