Skip to content

Commit

Permalink
disable proxy check (#560)
Browse files Browse the repository at this point in the history
* disable proxy access check by default

* remove
  • Loading branch information
augustbleeds authored Dec 1, 2024
1 parent 1cdb2cd commit 3f63ca6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion contracts/src/access_control/access_controller.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod AccessController {
#[constructor]
fn constructor(ref self: ContractState, owner_address: ContractAddress) {
self.ownable.initializer(owner_address);
self.access_control.initializer();
self.access_control.initializer(true);
}

#[abi(embed_v0)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/emergency/sequencer_uptime_feed.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ mod SequencerUptimeFeed {
ref self: ContractState, initial_status: u128, owner_address: ContractAddress
) {
self.ownable.initializer(owner_address);
self.access_control.initializer();
self.access_control.initializer(true);
let round_id = 1_u128;
let timestamp = starknet::info::get_block_timestamp();
let from_address = EthAddress {
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/libraries/access_control.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ mod AccessControlComponent {
impl Ownable: OwnableComponent::HasComponent<TContractState>,
+Drop<TContractState>,
> of InternalTrait<TContractState> {
fn initializer(ref self: ComponentState<TContractState>) {
self._check_enabled.write(true);
fn initializer(ref self: ComponentState<TContractState>, check_enabled: bool) {
self._check_enabled.write(check_enabled);
self.emit(Event::AccessControlEnabled(AccessControlEnabled {}));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/ocr2/aggregator.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ mod Aggregator {
description: felt252
) {
self.ownable.initializer(owner);
self.access_control.initializer();
self.access_control.initializer(true);
self._link_token.write(link);
self._billing_access_controller.write(billing_access_controller);

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/ocr2/aggregator_proxy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod AggregatorProxy {
#[constructor]
fn constructor(ref self: ContractState, owner: ContractAddress, address: ContractAddress) {
self.ownable.initializer(owner);
self.access_control.initializer();
self.access_control.initializer(false);
self._set_aggregator(address);
}

Expand Down
10 changes: 7 additions & 3 deletions contracts/src/tests/test_aggregator_proxy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use chainlink::ocr2::aggregator_proxy::AggregatorProxy;
use chainlink::ocr2::aggregator_proxy::AggregatorProxy::{
AggregatorProxyImpl, AggregatorProxyInternal, UpgradeableImpl
};
use chainlink::libraries::access_control::AccessControlComponent::AccessControlImpl;
use chainlink::libraries::access_control::{
IAccessControllerDispatcher, IAccessControllerDispatcherTrait,
AccessControlComponent::AccessControlImpl
};
use chainlink::ocr2::aggregator::Round;
use chainlink::utils::split_felt;
use chainlink::tests::test_ownable::should_implement_ownable;
Expand Down Expand Up @@ -99,6 +102,9 @@ fn test_access_control() {
.deploy(@calldata)
.unwrap();

// proxy by default disables the access check, so we re-enable for testing purposes
IAccessControllerDispatcher { contract_address: aggregatorProxyAddr }.enable_access_check();

should_implement_access_control(aggregatorProxyAddr, account);
}

Expand Down Expand Up @@ -134,7 +140,6 @@ fn test_query_latest_round_data() {
}

#[test]
#[should_panic(expected: ('user does not have read access',))]
fn test_query_latest_round_data_without_access() {
let (owner, mockAggregatorAddr, mockAggregator, _, _) = setup();
let mut state = STATE();
Expand All @@ -150,7 +155,6 @@ fn test_query_latest_round_data_without_access() {
}

#[test]
#[should_panic(expected: ('user does not have read access',))]
fn test_query_latest_answer_without_access() {
let (owner, mockAggregatorAddr, mockAggregator, _, _) = setup();
let mut state = STATE();
Expand Down

0 comments on commit 3f63ca6

Please sign in to comment.