Skip to content

Commit 1e6ec3c

Browse files
committed
fix: revert upgradeability and added a new functionality
1 parent 710a4f6 commit 1e6ec3c

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

contracts/Cross-chain/Voting/BlockHashDispatcher.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ contract BlockHashDispatcher is Pausable, OApp, Initializable {
4343
/// @notice Error thrown when an invalid chain ID is provided
4444
error InvalidChainEid(uint32 eid);
4545

46-
constructor(address endpoint_, address owner_) OApp(endpoint_, owner_) Ownable() {
46+
constructor(
47+
address endpoint_,
48+
address owner_,
49+
uint32 bnbChainEId_,
50+
uint32 chainId_
51+
) OApp(endpoint_, owner_) Ownable() {
4752
ensureNonzeroAddress(address(endpoint_));
48-
}
49-
50-
function initialize(uint32 bnbChainEId_, uint32 chainId_) external initializer {
5153
if (bnbChainEId_ == 0 || chainId_ == 0) {
5254
revert InvalidChainEid(0);
5355
}

contracts/Cross-chain/Voting/VotingPowerAggregator.sol

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import { ReadCodecV1, EVMCallComputeV1, EVMCallRequestV1 } from "@layerzerolabs/
1616
import { OAppOptionsType3 } from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OAppOptionsType3.sol";
1717
import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol";
1818
import { IXvsVault } from "../interfaces/IXvsVault.sol";
19-
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
2019

21-
contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initializable {
20+
contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3 {
2221
using ExcessivelySafeCall for address;
2322

2423
struct NetworkProposalBlockDetails {
@@ -154,16 +153,14 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
154153
*/
155154
error LZReceiveProposalNotExists(string reason);
156155

157-
constructor(address endpoint_, address delegate) OAppRead(endpoint_, delegate) {
158-
_disableInitializers();
159-
}
160-
161-
function initialize(
156+
constructor(
157+
address endpoint_,
158+
address delegate,
162159
uint32 readChannel,
163160
address warehouseAddress,
164161
address governorBravoAddress,
165162
address bscXvsVaultAddress
166-
) external initializer {
163+
) OAppRead(endpoint_, delegate) {
167164
ensureNonzeroAddress(warehouseAddress);
168165
ensureNonzeroAddress(governorBravoAddress);
169166
ensureNonzeroAddress(bscXvsVaultAddress);
@@ -172,8 +169,7 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
172169
bscXvsVault = IXvsVault(bscXvsVaultAddress);
173170

174171
// Set the read channel
175-
READ_CHANNEL = readChannel;
176-
setReadChannel(READ_CHANNEL, true);
172+
setReadChannel(readChannel, true);
177173
}
178174

179175
/**
@@ -192,16 +188,6 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
192188
_unpause();
193189
}
194190

195-
/**
196-
* @notice Sets the LayerZero read channel, enabling or disabling it based on `_active`.
197-
* @param _channelId The channel ID to set.
198-
* @param _active Flag to activate or deactivate the channel.
199-
*/
200-
function setReadChannel(uint32 _channelId, bool _active) public override onlyOwner {
201-
_setPeer(_channelId, _active ? AddressCast.toBytes32(address(this)) : bytes32(0));
202-
READ_CHANNEL = _channelId;
203-
}
204-
205191
/**
206192
* @notice Updates the network configuration for a given chain ID.
207193
* @param remoteChainEid The chain ID for which to update the configuration.
@@ -291,7 +277,10 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
291277
}
292278
}
293279

294-
proposalBlockDetails[pId][BSC_CHAIN_ID] = NetworkProposalBlockDetails(block.number - 1, blockhash(block.number - 1));
280+
proposalBlockDetails[pId][BSC_CHAIN_ID] = NetworkProposalBlockDetails(
281+
block.number - 1,
282+
blockhash(block.number - 1)
283+
);
295284

296285
uint96 power = getVotingPower(proposer, pId, proposerVotingProofs);
297286
if (power < proposalThreshold) {
@@ -302,7 +291,26 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
302291
}
303292

304293
/**
305-
* @notice Sends a read request to LayerZero, querying Uniswap QuoterV2 for WETH/USDC prices on configured chains.
294+
* @notice Sets the LayerZero read channel, enabling or disabling it based on `_active`.
295+
* @param _channelId The channel ID to set.
296+
* @param _active Flag to activate or deactivate the channel.
297+
*/
298+
function setReadChannel(uint32 _channelId, bool _active) public override onlyOwner {
299+
_setPeer(_channelId, _active ? AddressCast.toBytes32(address(this)) : bytes32(0));
300+
READ_CHANNEL = _channelId;
301+
}
302+
303+
/**
304+
* @notice It will change the delegate in the endpoint.
305+
* @param delegate delegate is authorized by the oapp to configure anything in layerzero
306+
*/
307+
function setEndpointDelegate(address delegate) external onlyOwner {
308+
endpoint.setDelegate(delegate);
309+
}
310+
311+
/**
312+
* @notice Sends a read request to LayerZero, querying block hashes from remote chains for a given proposal.
313+
* @param proposalId Unique Id of the proposal.
306314
* @param _extraOptions Additional messaging options, including gas and fee settings.
307315
* @return receipt The LayerZero messaging receipt for the request.
308316
*/
@@ -332,7 +340,10 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
332340
}
333341

334342
/**
335-
* @notice Quotes the estimated messaging fee for querying Uniswap QuoterV2 for WETH/USDC prices.
343+
* @notice Quotes the estimated messaging fee for querying block hashes from remote chains for a given proposal.
344+
* @param proposalId Unique id of a proposal .
345+
* @param remoteTargetEids Array of LayerZero Endpoint ids for the target remote chains.
346+
* @param blockNumbers Array of block numbers to query hashes for on the remote chains.
336347
* @param _extraOptions Additional messaging options.
337348
* @param _payInLzToken Boolean flag indicating whether to pay in LayerZero tokens.
338349
* @return fee The estimated messaging fee.
@@ -350,6 +361,9 @@ contract VotingPowerAggregator is Pausable, OAppRead, OAppOptionsType3, Initiali
350361

351362
/**
352363
* @notice Constructs a command to query the Uniswap QuoterV2 for WETH/USDC prices on all configured chains.
364+
* @param proposalId Unique id of proposal.
365+
* @param remoteTargetEids Array of LayerZero Endpoint IDs for the target remote chains.
366+
* @param blockNumbers Array of block numbers to query hashes for on the remote chains.
353367
* @return cmd The encoded command to request Uniswap quotes.
354368
*/
355369
function getCmd(

0 commit comments

Comments
 (0)