Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ BASE_SEPOLIA_RPC="https://rpc.ankr.com/base_sepolia"
# EVMx key addresses
# Find the most up to date addresses in deployments/dev_addresses.json
ADDRESS_RESOLVER="0xf3046B22F98C25305E8040286fB1b33378BA10a1"
AUCTION_MANAGER="0x5d6d4DCb0F719F01441377F633F3EdD186e19360"
FEES_MANAGER="0x603723100172D30171B7Fd9870ba80F8baf6FaD4"
ARBITRUM_FEES_PLUG="0x89324F93d852cB4fcDC4Ee202456be466ce096bb"

Expand Down
10 changes: 7 additions & 3 deletions contracts/base/AppGatewayBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "../interfaces/IPromise.sol";

import {FeesPlugin} from "../protocol/utils/FeesPlugin.sol";
import {InvalidPromise, FeesNotSet} from "../protocol/utils/common/Errors.sol";
import {FAST} from "../protocol/utils/common/Constants.sol";

/// @title AppGatewayBase
/// @notice Abstract contract for the app gateway
Expand Down Expand Up @@ -51,12 +52,15 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin

/// @notice Constructor for AppGatewayBase
/// @param addressResolver_ The address resolver address
constructor(address addressResolver_, address auctionManager_, bytes32 sbType_) {
constructor(address addressResolver_) {
_setAddressResolver(addressResolver_);
auctionManager = auctionManager_;
sbType = FAST;
}
/// @notice Sets the switchboard type
/// @param sbType_ The switchboard type
function _setSbType(bytes32 sbType_) internal {
sbType = sbType_;
}

/// @notice Creates a contract ID
/// @param contractName_ The contract name
/// @return bytes32 The contract ID
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/ProxyFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import {ERC1967Factory} from "solady/utils/ERC1967Factory.sol";

contract ProxyFactory is ERC1967Factory {
constructor() {}
}
}
5 changes: 5 additions & 0 deletions contracts/interfaces/IAddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ interface IAddressResolver {
/// @dev Returns interface pointing to zero address if not configured
function feesManager() external view returns (address);

/// @notice Gets the address of the default auction manager contract
/// @return IAuctionManager The auction manager interface
/// @dev Returns interface pointing to zero address if not configured
function defaultAuctionManager() external view returns (address);

/// @notice Gets the watcher precompile contract interface
/// @return IWatcherPrecompile The watcher precompile interface
/// @dev Returns interface pointing to zero address if not configured
Expand Down
13 changes: 11 additions & 2 deletions contracts/protocol/AddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ abstract contract AddressResolverStorage is IAddressResolver {
// slot 60
mapping(address => address) public override contractsToGateways;

// slots [61-110] reserved for gap
uint256[50] _gap_after;
// slot 61
address public override defaultAuctionManager;

// slots [62-110] reserved for gap
uint256[49] _gap_after;
}

/// @title AddressResolver Contract
Expand Down Expand Up @@ -250,6 +253,12 @@ contract AddressResolver is AddressResolverStorage, Initializable, Ownable {
feesManager = feesManager_;
}

/// @notice Updates the address of the default auction manager
/// @param defaultAuctionManager_ The address of the default auction manager
function setDefaultAuctionManager(address defaultAuctionManager_) external onlyOwner {
defaultAuctionManager = defaultAuctionManager_;
}

/// @notice Updates the address of the watcher precompile contract
/// @param watcherPrecompile_ The address of the watcher precompile contract
function setWatcherPrecompile(address watcherPrecompile_) external onlyOwner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ abstract contract BatchAsync is QueueAsync {
}

// Default flow for other cases (including mixed read/write)
if (auctionManager_ == address(0)) {
auctionManager_ = IAddressResolver(addressResolver__).defaultAuctionManager();
}
return _deliverPayload(payloadDetailsArray, fees_, auctionManager_, onCompleteData_);
}

Expand Down Expand Up @@ -311,6 +314,9 @@ abstract contract BatchAsync is QueueAsync {
amount_,
receiver_
);
if (auctionManager_ == address(0)) {
auctionManager_ = IAddressResolver(addressResolver__).defaultAuctionManager();
}
_deliverPayload(payloadDetailsArray, fees_, auctionManager_, new bytes(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract DeliveryHelper is BatchAsync {
if (payloadBatch.lastBatchPromises.length > 0) {
// Check if all promises are resolved
for (uint256 i = 0; i < payloadBatch.lastBatchPromises.length; i++) {
if (payloadBatch.lastBatchPromises[i] == address(0)) continue;
if (!IPromise(payloadBatch.lastBatchPromises[i]).resolved()) {
if (isCallback_) revert PromisesNotResolved();
}
Expand Down
60 changes: 32 additions & 28 deletions contracts/protocol/utils/common/Structs.sol
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

//// ENUMS ////

enum CallType {
READ,
WRITE,
DEPLOY,
WITHDRAW
}

enum Read {
OFF,
ON
enum IsPlug {
YES,
NO
}

enum Parallel {
OFF,
ON
}

enum IsPlug {
YES,
NO
enum Read {
OFF,
ON
}

//// STRUCTS ////

struct AppGatewayConfig {
address plug;
address appGateway;
Expand All @@ -44,21 +48,25 @@ struct AsyncRequest {
address[] next;
}

struct AttestAndExecutePayloadParams {
bytes32 payloadId;
bytes32 digest;
address switchboard;
address appGateway;
address target;
uint256 executionGasLimit;
uint256 deadline;
bytes proof;
bytes transmitterSignature;
bytes payload;
}

struct Bid {
address transmitter;
uint256 fee;
bytes extraData;
}

struct CallFromChainParams {
bytes32 callId;
bytes32 params;
address plug;
address appGateway;
uint32 chainSlug;
bytes payload;
}

struct CallParams {
IsPlug isPlug;
address asyncPromise;
Expand All @@ -72,24 +80,20 @@ struct CallParams {
bytes initCallData;
}

struct CallFromChainParams {
bytes32 callId;
bytes32 params;
address plug;
address appGateway;
uint32 chainSlug;
bytes payload;
}

struct DeployParams {
address contractAddr;
bytes bytecode;
}

struct AttestAndExecutePayloadParams {
bytes32 payloadId;
bytes32 digest;
address switchboard;
address appGateway;
address target;
uint256 executionGasLimit;
uint256 deadline;
bytes proof;
bytes transmitterSignature;
bytes payload;
}

struct Fees {
uint32 feePoolChain;
address feePoolToken;
Expand Down
8 changes: 8 additions & 0 deletions hardhat-scripts/deploy/1.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ const deployEVMxContracts = async () => {
deployUtils.signer
);

await updateContractSettings(
addressResolver,
"defaultAuctionManager",
"setDefaultAuctionManager",
deployUtils.addresses[EVMxCoreContracts.AuctionManager],
deployUtils.signer
);

await updateContractSettings(
addressResolver,
"watcherPrecompile__",
Expand Down
66 changes: 25 additions & 41 deletions hardhat-scripts/deploy/5.upload.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
import {
ChainAddressesObj,
EVMxAddressesObj,
ChainSlug,
DeploymentMode,
EVMxAddressesObj,
chainSlugToHardhatChainName,
ChainSlug
} from "@socket.tech/socket-protocol-common";
import { config as dotenvConfig } from "dotenv";
import fs from "fs";
Expand Down Expand Up @@ -58,52 +59,35 @@ type ConfigEntry = {
eventBlockRange: number;
addresses?: ChainAddressesObj | EVMxAddressesObj;
};

type S3Config = {
[chainId: string]: ConfigEntry;
};

const supportedChainSlugs = [EVMX_CHAIN_ID as ChainSlug, ...chains];

export let config: S3Config = {
[ChainSlug.ARBITRUM_SEPOLIA]: {
eventBlockRangePerCron: 5000,
rpc: process.env.ARBITRUM_SEPOLIA_RPC,
wssRpc: process.env.ARBITRUM_SEPOLIA_WSS_RPC,
confirmations: 0,
eventBlockRange: 5000,
},
[ChainSlug.OPTIMISM_SEPOLIA]: {
eventBlockRangePerCron: 5000,
rpc: process.env.OPTIMISM_SEPOLIA_RPC,
wssRpc: process.env.OPTIMISM_SEPOLIA_WSS_RPC,
confirmations: 0,
eventBlockRange: 5000,
},
[ChainSlug.SEPOLIA]: {
eventBlockRangePerCron: 5000,
rpc: process.env.SEPOLIA_RPC,
wssRpc: process.env.SEPOLIA_WSS_RPC,
confirmations: 0,
eventBlockRange: 5000,
},
[EVMX_CHAIN_ID]: {
eventBlockRangePerCron: 5000,
rpc: process.env.EVMX_RPC,
wssRpc: process.env.EVMX_WSS_RPC,
confirmations: 0,
eventBlockRange: 5000,
},
[ChainSlug.BASE_SEPOLIA]: {
//@ts-ignore
supportedChainSlugs,
};

// Add config for each supported chain
supportedChainSlugs.forEach(chainSlug => {
let chainName =
chainSlug === EVMX_CHAIN_ID ? "EVMX" : chainSlugToHardhatChainName[chainSlug].toString().replace("-", "_");
let rpcKey = `${chainName.toUpperCase()}_RPC`;
let wssRpcKey = `${chainName.toUpperCase()}_WSS_RPC`;
if (!process.env[rpcKey] || !process.env[wssRpcKey]) {
console.log(`Missing RPC or WSS RPC for chain ${chainName}`);
return;
}
config[chainSlug] = {
eventBlockRangePerCron: 5000,
rpc: process.env.BASE_SEPOLIA_RPC,
wssRpc: process.env.BASE_SEPOLIA_WSS_RPC,
rpc: process.env[rpcKey],
wssRpc: process.env[wssRpcKey],
confirmations: 0,
eventBlockRange: 5000,
},
//@ts-ignore
supportedChainSlugs: [
...chains,
EVMX_CHAIN_ID,
],
};
};
});
// Read the addresses.json file
const addressesPath = path.join(__dirname, getAddressesPath());
const addresses = JSON.parse(fs.readFileSync(addressesPath, "utf8"));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@aws-sdk/client-s3": "^3.670.0",
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@nomiclabs/hardhat-ethers": "2.2.3",
"@socket.tech/socket-protocol-common": "1.1.27",
"@socket.tech/socket-protocol-common": "1.1.31",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "6.0.0",
"dotenv": "^16.0.3",
Expand Down
5 changes: 1 addition & 4 deletions script/counter/DeployEVMxCounterApp.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {CounterAppGateway} from "../../test/apps/app-gateways/counter/CounterAppGateway.sol";
import {Fees} from "../../contracts/protocol/utils/common/Structs.sol";
import {ETH_ADDRESS, FAST} from "../../contracts/protocol/utils/common/Constants.sol";
import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol";

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

Expand All @@ -26,8 +25,6 @@ contract CounterDeploy is Script {

CounterAppGateway gateway = new CounterAppGateway(
addressResolver,
auctionManager,
FAST,
fees
);

Expand Down
Loading
Loading