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

Non evm support and additional ccr functions integration #422

Merged
merged 34 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2e34a3a
feat: added bytes32ToAddress in BaseHelper lib
0xNilesh Jul 23, 2024
0d85aa6
refactor: updated address parameters to bytes32 in CCR payloads decoding
0xNilesh Jul 23, 2024
2f92165
test: updated tests as per bytes32 new changes
0xNilesh Jul 23, 2024
e218655
fix: updated sender as bytes32
0xNilesh Jul 23, 2024
74e1d71
Merge pull request #408 from push-protocol/407-ccr-sender-bytes32
Zartaj0 Jul 24, 2024
9178079
support bytes32 for address
Zartaj0 Jul 24, 2024
1777c0b
Merge remote-tracking branch 'origin/feat/non-evm-support-ccr' into 4…
Zartaj0 Jul 24, 2024
e809640
Address to Bytes related changes
Zartaj0 Jul 25, 2024
321caad
Merge pull request #410 from push-protocol/403-address-to-bytes32
0xNilesh Jul 25, 2024
e8e17b1
Add CCR support for updateChannelMeta
Zartaj0 Jul 26, 2024
f93cdb5
feat: add ccr support for createChannelSettings fn
0xNilesh Jul 26, 2024
9d2f335
name update
Zartaj0 Jul 29, 2024
5ac31b4
Add CCR for UpdateChannelState
Zartaj0 Jul 30, 2024
ee59007
Merge pull request #412 from push-protocol/403-enable-updatechannelme…
0xNilesh Jul 30, 2024
48a702e
ci: merge branch 'feat/non-evm-support-ccr' into ccr/411-createChanne…
0xNilesh Jul 30, 2024
28d82ad
Merge remote-tracking branch 'origin/feat/non-evm-support-ccr' into C…
Zartaj0 Jul 30, 2024
53b9982
file name fix
Zartaj0 Jul 30, 2024
1010ff6
Merge pull request #413 from push-protocol/ccr/411-createChannelSetti…
Zartaj0 Jul 30, 2024
6c9fa98
Merge remote-tracking branch 'origin/feat/non-evm-support-ccr' into C…
Zartaj0 Jul 30, 2024
705b69f
test fix
Zartaj0 Jul 31, 2024
3ede041
Re factor functions
Zartaj0 Aug 1, 2024
79dc380
merged similar checks
Zartaj0 Aug 2, 2024
b60fc89
name fix and check shift
Zartaj0 Aug 2, 2024
83a5130
fix tree
Zartaj0 Aug 2, 2024
4ed2b4e
fix if block
Zartaj0 Aug 6, 2024
fe51df5
Merge pull request #415 from push-protocol/CCR-support-for-UpdateChan…
0xNilesh Aug 6, 2024
35b7639
refactor: updated address param in events to bytes32 for consistency
0xNilesh Aug 7, 2024
4a0467e
tests: updated test cases with event changes
0xNilesh Aug 7, 2024
092be11
git: resolve merge conflicts
0xNilesh Aug 7, 2024
db6d027
Merge branch '212-crossChainReq-1st' into feat/non-evm-support-ccr
0xNilesh Aug 7, 2024
d3d5a7b
fix test cases and structure
Zartaj0 Aug 8, 2024
7ad949d
Merge pull request #423 from push-protocol/fix-failing-test-cases
0xNilesh Aug 8, 2024
d5661c0
removed unUsed state
zaryab2000 Aug 13, 2024
bdd1c05
removed ChatDetails+userChatData
zaryab2000 Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion contracts/PushComm/PushCommEthStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ contract PushCommEthStorageV2 {
// New State Variables
address public PUSH_TOKEN_ADDRESS;

mapping(address => CommTypes.ChatDetails) public userChatData;
mapping(bytes32 => string) public walletToPGP;
uint256 FEE_AMOUNT;
}
1 change: 0 additions & 1 deletion contracts/PushComm/PushCommStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ contract PushCommStorageV2 {
// New State Variables
IERC20 public PUSH_NTT;

mapping(address => CommTypes.ChatDetails) public userChatData;
mapping(bytes32 => string) public walletToPGP;

// WORMHOLE CROSS-CHAIN STATE VARIABLES
Expand Down
43 changes: 23 additions & 20 deletions contracts/PushComm/PushCommV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,10 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp
whenNotPaused
{
// Implement restrictions based on functionType
if (functionType == CrossChainRequestTypes.CrossChainFunction.AddChannel) {

if (functionType == CrossChainRequestTypes.CrossChainFunction.AddChannel ||
zaryab2000 marked this conversation as resolved.
Show resolved Hide resolved
functionType == CrossChainRequestTypes.CrossChainFunction.CreateChannelSettings ||
functionType == CrossChainRequestTypes.CrossChainFunction.ReactivateChannel ) {
if (amount < ADD_CHANNEL_MIN_FEES) {
revert Errors.InvalidArg_LessThanExpected(ADD_CHANNEL_MIN_FEES, amount);
}
Expand All @@ -591,10 +594,7 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp
if (amount == 0) {
zaryab2000 marked this conversation as resolved.
Show resolved Hide resolved
revert Errors.InvalidArg_LessThanExpected(1, amount);
}
} else {
revert Errors.Comm_InvalidCrossChain_Function();
}

bytes memory requestPayload = abi.encode(functionType, payload, amount, msg.sender);

// Call the internal function to create the cross-chain request
Expand All @@ -614,25 +614,28 @@ contract PushCommV3 is Initializable, PushCommStorageV2, IPushCommV3, PausableUp

uint256 messageBridgeCost = quoteMsgRelayCost(recipientChain, gasLimit);
uint256 tokenBridgeCost = quoteTokenBridgingCost();
if (msg.value < (messageBridgeCost + tokenBridgeCost)) {
address coreAddress = EPNSCoreAddress;
if (amount != 0) {
if (msg.value < (messageBridgeCost + tokenBridgeCost)) {
revert Errors.InsufficientFunds();
}
IERC20 PushNtt = PUSH_NTT;
INttManager NttManager = NTT_MANAGER;

PushNtt.transferFrom(msg.sender, address(this), amount);
PushNtt.approve(address(NttManager), amount);
NttManager.transfer{ value: tokenBridgeCost }(
amount,
recipientChain,
BaseHelper.addressToBytes32(coreAddress),
BaseHelper.addressToBytes32(msg.sender),
false,
new bytes(1)
);
} else if (msg.value < (messageBridgeCost)) {
revert Errors.InsufficientFunds();
}

IERC20 PushNtt = PUSH_NTT;
INttManager NttManager = NTT_MANAGER;
address coreAddress = EPNSCoreAddress;

PushNtt.transferFrom(msg.sender, address(this), amount);
PushNtt.approve(address(NttManager), amount);
NttManager.transfer{ value: tokenBridgeCost }(
amount,
recipientChain,
BaseHelper.addressToBytes32(coreAddress),
BaseHelper.addressToBytes32(msg.sender),
false,
new bytes(1)
);

// Relay the RequestData Payload
WORMHOLE_RELAYER.sendPayloadToEvm{ value: messageBridgeCost }(
recipientChain,
Expand Down
8 changes: 3 additions & 5 deletions contracts/PushCore/PushCoreStorageV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract PushCoreStorageV2 {
);

mapping(address => uint256) public nonces; // NOT IN USE Anymore
mapping(address => uint256) public channelUpdateCounter;
mapping(address => uint256) public oldChannelUpdateCounter;//NOT in use anymore
Copy link
Collaborator

Choose a reason for hiding this comment

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

We directly reject the use of old ChannelUpdateCounter mapping but what about the data it already stores for existing addresses ?? Has there any measures been implemented for the migration of those data?
cc: @0xNilesh

Copy link
Collaborator

Choose a reason for hiding this comment

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

two things here:

  1. It should first be checked if there are existing use of this oldChannelUpdateCounter currently?
  2. We should include functionality for the migration of this data as well from address to bytes.

Note: Ideally, every address to bytes change should be re-checked for migration again. @0xNilesh @Zartaj0

Copy link
Member

Choose a reason for hiding this comment

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

This might have slipped.

Yes, we planned to include its migration in the same migrate function we have for channelInfo.

/**
* Staking V2 state variables *
*/
Expand All @@ -36,9 +36,6 @@ contract PushCoreStorageV2 {
*/
mapping(address => uint256) public celebUserFunds;

/* *** v2.5 State variables *** */
address public feePoolStakingContract;

/* *** V3 State variables *** */
// WORMHOLE Cross-Chain State

Expand All @@ -48,5 +45,6 @@ contract PushCoreStorageV2 {
mapping(address => uint256) public arbitraryReqFees; // ToDo: Could be replaced with nonces(unused) mapping instead
// of adding new state

mapping(bytes32 => CoreTypes.Channel) public channelInfo;
mapping(bytes32 => CoreTypes.Channel) public channelInfo;
mapping(bytes32 => uint256) public channelUpdateCounter;
}
Loading