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

disable proxy access check by default #547

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
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 @@ -258,7 +258,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 @@ -136,8 +136,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 @@ -398,7 +398,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 @@ -174,7 +174,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 @@ -89,6 +92,9 @@ fn test_access_control() {

let (aggregatorProxyAddr, _) = declare("AggregatorProxy").unwrap().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 @@ -124,7 +130,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 @@ -140,7 +145,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
Loading