Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c270cd8
forge install: solady
rookmate Feb 22, 2025
63ef8c3
Update repo to latest version
rookmate Feb 22, 2025
f9fb895
update socket-protocol submodule to staging branch
rookmate Feb 22, 2025
79c0944
Add remappings file
rookmate Feb 22, 2025
ef3dba7
Update foundry.toml
rookmate Feb 22, 2025
81a0796
feat: change rpc url
arthcp Feb 22, 2025
91084ee
Update protocol staging version
rookmate Feb 27, 2025
ea2690d
Simplify src folder structure
rookmate Feb 27, 2025
ad3293e
Update solidity files
rookmate Feb 27, 2025
87c3865
Update foundry.toml
rookmate Feb 27, 2025
9e67668
Update remappings
rookmate Feb 27, 2025
dce5874
Update devnet details
rookmate Feb 27, 2025
946ebf7
Update API URL
rookmate Feb 27, 2025
c5e2635
Fix chainId and formating
rookmate Feb 27, 2025
36bce8a
Fix to writePayloads
rookmate Feb 27, 2025
d7a7de4
Fix chain ID
rookmate Feb 27, 2025
018c406
Reduce fee amount on Counter deployment
rookmate Feb 28, 2025
b622620
Update socket-protocol submodule
rookmate Feb 28, 2025
2489a71
Add script to update socket protocol submodule
rookmate Feb 28, 2025
f280b0f
Update script to allow for untracked files
rookmate Feb 28, 2025
ecc820b
Update devnet addresses
rookmate Feb 28, 2025
c9e6ecb
Only send tx onchain if there are instances found
rookmate Feb 28, 2025
8a829b8
Add deploy onchain to optimism and base
rookmate Feb 28, 2025
da04645
Add forwarder address deployment validation
rookmate Mar 3, 2025
168600c
Update withdraw fee estimate
rookmate Mar 3, 2025
b0a02d6
Improve logging
rookmate Mar 3, 2025
b5fb9ac
Fix chain id on deploy onchain contracts
rookmate Mar 3, 2025
304072d
Update to track master instead of staging
rookmate Mar 3, 2025
b011966
Update socket-protocol submodule
rookmate Mar 3, 2025
f3a0041
Remove Auction Manager as a mandatory input parameter
rookmate Mar 3, 2025
8d8bbf9
Update .env.sample
rookmate Mar 3, 2025
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
34 changes: 17 additions & 17 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PRIVATE_KEY="0x"
WALLET_ADDRESS="0x"

OFF_CHAIN_VM_RPC="https://rpc-socket-composer-testnet.t.conduit.xyz"

# RPCs
EVMX_RPC="https://rpc-evmx-devnet.socket.tech/"
SEPOLIA_RPC="https://rpc.ankr.com/eth_sepolia/"
SEPOLIA_API_KEY="empty"

ARBITRUM_SEPOLIA_RPC="https://rpc.ankr.com/arbitrum_sepolia"
ARBITRUM_API_KEY="empty"

OPTIMISM_SEPOLIA_RPC="https://rpc.ankr.com/optimism_sepolia"
OPTIMISM_API_KEY="empty"

BASE_SEPOLIA_RPC="https://rpc.ankr.com/base_sepolia"
BASE_API_KEY="empty"

ADDRESS_RESOLVER="0x6f60df8CD3Bb76C33ebc9E2E2Fe577edD62e3938"
AUCTION_MANAGER="0xDC81d1BE1E8d92C5a98a15D89A16134D74121FC2"
# EVMx key addresses
# Find the most up to date addresses in deployments/dev_addresses.json
ADDRESS_RESOLVER="0xf3046B22F98C25305E8040286fB1b33378BA10a1"
FEES_MANAGER="0x603723100172D30171B7Fd9870ba80F8baf6FaD4"
ARBITRUM_FEES_PLUG="0x89324F93d852cB4fcDC4Ee202456be466ce096bb"

# Add your deployer private key here
# or remove it from this file if it is already an env var
PRIVATE_KEY="0x"

# Set app related values after deployment on EVMx
APP_GATEWAY="0x"

# Set values after deployment
COUNTER_DEPLOYER=""
COUNTER_APP_GATEWAY=""
# FOR INFRASTRUCTURE DEPLOYMENT ONLY
# Removes hardhat issues related to linting and syntax checking
SOCKET_SIGNER_KEY="0000dead0000dead0000dead0000dead0000dead0000dead0000dead0000dead"
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
url = https://github.com/foundry-rs/forge-std
[submodule "lib/socket-protocol"]
path = lib/socket-protocol
url = https://github.com/SocketDotTech/socket-protocol
url = https://github.com/SocketDotTech/socket-protocol.git
branch = master
9 changes: 9 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[profile.default]
solc_version = "0.8.22"
src = "src"
out = "out"
libs = ["lib"]
ffi = true
optimizer = true
optimizer_runs = 200
evm_version = 'paris'

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[etherscan]
43 = { key = "empty", url = "https://evmx.cloud.blockscout.com/api?" }
421614 = { key = "${ARBISCAN_API_KEY}", url = "https://api-sepolia.arbiscan.io/api?" }
11155420 = { key = "${OPTIMISM_API_KEY}", url = "https://optimism-sepolia.blockscout.com/api?" }
2 changes: 1 addition & 1 deletion lib/socket-protocol
Submodule socket-protocol updated 188 files
5 changes: 5 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ds-test/=lib/socket-protocol/lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
socket-protocol/=lib/socket-protocol/
solady/=lib/socket-protocol/lib/solady/src/
solmate/=lib/socket-protocol/lib/solmate/src/
33 changes: 33 additions & 0 deletions script/counter/DeployEVMxCounterApp.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol";
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";

import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";

contract CounterDeploy is Script {
function run() external {
address addressResolver = vm.envAddress("ADDRESS_RESOLVER");
string memory rpc = vm.envString("EVMX_RPC");
vm.createSelectFork(rpc);

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

// Setting fee payment on Arbitrum Sepolia
// amount: Minimum fee required in contract and maximum user is willing to pay
// User must have deposited >= amount, ensuring transmitter gets compensated for including this tx in a batch
// Current Counter example costs 0.000105 eth
Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether});

CounterAppGateway gateway = new CounterAppGateway(addressResolver, fees);

console.log("Contracts deployed:");
console.log("CounterAppGateway:", address(gateway));
console.log("counterId:");
console.logBytes32(gateway.counter());
}
}
30 changes: 30 additions & 0 deletions script/counter/DeployOnchainCounters.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";

import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";

contract CounterDeployOnchain is Script {
function run() external {
string memory rpc = vm.envString("EVMX_RPC");
console.log(rpc);
vm.createSelectFork(rpc);

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

CounterAppGateway appGateway = CounterAppGateway(vm.envAddress("APP_GATEWAY"));

console.log("Counter Gateway:", address(appGateway));

console.log("Deploying contracts on Arbitrum Sepolia...");
appGateway.deployContracts(421614);
console.log("Deploying contracts on Optimism Sepolia...");
appGateway.deployContracts(11155420);
console.log("Deploying contracts on Base Sepolia...");
appGateway.deployContracts(84532);
}
}
56 changes: 56 additions & 0 deletions script/counter/IncrementCountersFromApp.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";

import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";

contract IncrementCounters is Script {
function run() external {
string memory socketRPC = vm.envString("EVMX_RPC");
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

vm.createSelectFork(socketRPC);

CounterAppGateway gateway = CounterAppGateway(vm.envAddress("APP_GATEWAY"));

address counterForwarderArbitrumSepolia = gateway.forwarderAddresses(gateway.counter(), 421614);
address counterForwarderOptimismSepolia = gateway.forwarderAddresses(gateway.counter(), 11155420);
address counterForwarderBaseSepolia = gateway.forwarderAddresses(gateway.counter(), 84532);

// Count non-zero addresses
uint256 nonZeroCount = 0;
if (counterForwarderArbitrumSepolia != address(0)) nonZeroCount++;
if (counterForwarderOptimismSepolia != address(0)) nonZeroCount++;
if (counterForwarderBaseSepolia != address(0)) nonZeroCount++;

address[] memory instances = new address[](nonZeroCount);
uint256 index = 0;
if (counterForwarderArbitrumSepolia != address(0)) {
instances[index] = counterForwarderArbitrumSepolia;
index++;
} else {
console.log("Arbitrum Sepolia forwarder not yet deployed");
}
if (counterForwarderOptimismSepolia != address(0)) {
instances[index] = counterForwarderOptimismSepolia;
index++;
} else {
console.log("Optimism Sepolia forwarder not yet deployed");
}
if (counterForwarderBaseSepolia != address(0)) {
instances[index] = counterForwarderBaseSepolia;
index++;
} else {
console.log("Base Sepolia forwarder not yet deployed");
}

if (instances.length > 0) {
vm.startBroadcast(deployerPrivateKey);
gateway.incrementCounters(instances);
} else {
console.log("No forwarder addresses found");
}
}
}
43 changes: 43 additions & 0 deletions script/counter/ReadOnchainCounters.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";

import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";
import {Counter} from "../../src/counter/Counter.sol";

contract CheckCounters is Script {
function run() external {
CounterAppGateway gateway = CounterAppGateway(vm.envAddress("APP_GATEWAY"));

vm.createSelectFork(vm.envString("EVMX_RPC"));
address counterInstanceArbitrumSepolia = gateway.getOnChainAddress(gateway.counter(), 421614);
address counterInstanceOptimismSepolia = gateway.getOnChainAddress(gateway.counter(), 11155420);
address counterInstanceBaseSepolia = gateway.getOnChainAddress(gateway.counter(), 84532);

if (counterInstanceArbitrumSepolia != address(0)) {
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
uint256 counterValueArbitrumSepolia = Counter(counterInstanceArbitrumSepolia).counter();
console.log("Counter value on Arbitrum Sepolia: ", counterValueArbitrumSepolia);
} else {
console.log("Counter not yet deployed on Arbitrum Sepolia");
}

if (counterInstanceOptimismSepolia != address(0)) {
vm.createSelectFork(vm.envString("OPTIMISM_SEPOLIA_RPC"));
uint256 counterValueOptimismSepolia = Counter(counterInstanceOptimismSepolia).counter();
console.log("Counter value on Optimism Sepolia: ", counterValueOptimismSepolia);
} else {
console.log("Counter not yet deployed on Optimism Sepolia");
}

if (counterInstanceBaseSepolia != address(0)) {
vm.createSelectFork(vm.envString("BASE_SEPOLIA_RPC"));
uint256 counterValueBaseSepolia = Counter(counterInstanceBaseSepolia).counter();
console.log("Counter value on Base Sepolia: ", counterValueBaseSepolia);
} else {
console.log("Counter not yet deployed on Base Sepolia");
}
}
}
58 changes: 58 additions & 0 deletions script/counter/WithdrawFeesArbitrumFeesPlug.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {FeesManager} from "socket-protocol/contracts/protocol/payload-delivery/FeesManager.sol";
import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol";

import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";

// @notice This script is used to withdraw fees from EVMX to Arbitrum Sepolia
// @dev Make sure your app has withdrawFeeTokens() function implemented. You can check its implementation in CounterAppGateway.sol
contract WithdrawFees is Script {
function run() external {
// EVMX Check available fees
vm.createSelectFork(vm.envString("EVMX_RPC"));
FeesManager feesManager = FeesManager(payable(vm.envAddress("FEES_MANAGER")));
address appGatewayAddress = vm.envAddress("APP_GATEWAY");

CounterAppGateway appGateway = CounterAppGateway(appGatewayAddress);
uint256 availableFees = feesManager.getAvailableFees(421614, appGatewayAddress, ETH_ADDRESS);
console.log("Available fees:", availableFees);

if (availableFees > 0) {
// Switch to Arbitrum Sepolia to get gas price
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
uint256 privateKey = vm.envUint("PRIVATE_KEY");
address sender = vm.addr(privateKey);

// Gas price from Arbitrum
uint256 arbitrumGasPrice = block.basefee + 0.1 gwei; // With buffer
uint256 gasLimit = 3_000_000; // Estimate
uint256 estimatedGasCost = gasLimit * arbitrumGasPrice;

console.log("Arbitrum gas price (wei):", arbitrumGasPrice);
console.log("Gas limit:", gasLimit);
console.log("Estimated gas cost:", estimatedGasCost);

// Calculate amount to withdraw
uint256 amountToWithdraw = availableFees > estimatedGasCost ? availableFees - estimatedGasCost : 0;

if (amountToWithdraw > 0) {
// Switch back to EVMX to perform withdrawal
vm.createSelectFork(vm.envString("EVMX_RPC"));
vm.startBroadcast(privateKey);
console.log("Withdrawing amount:", amountToWithdraw);
appGateway.withdrawFeeTokens(421614, ETH_ADDRESS, amountToWithdraw, sender);
vm.stopBroadcast();

// Switch back to Arbitrum Sepolia to check final balance
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
console.log("Final sender balance:", sender.balance);
} else {
console.log("Available fees less than estimated gas cost");
}
}
}
}
59 changes: 0 additions & 59 deletions script/counter/checkCounters.s.sol

This file was deleted.

32 changes: 0 additions & 32 deletions script/counter/deployCounterOffchain.s.sol

This file was deleted.

Loading
Loading