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

refactor(executor): thread local instead of global variable #1280

Merged
merged 6 commits into from
Aug 2, 2023

Conversation

KaoImin
Copy link
Contributor

@KaoImin KaoImin commented Jul 21, 2023

What this PR does / why we need it:

This PR:
Divide the global variable of system contract roots (header cell root and metadata root) into two parts:

  1. Two thread local storage that use in the exec() function. The local keys are loaded at the start of execution, and the life cycle is the exec() function. It is use for transactions execution. It is use for transactions executions.
  2. Other using the system contract roots places change to get them from the DB as following:
let state_root = self.storage.get_latest_block_header(ctx).await?.state_root;
let backend = AxonExecutorAdapter::from_root(
    state_root,
    Arc::clone(&self.trie_db),
    Arc::clone(&self.storage),
    Default::default(),
)?;
let root = backend.get_metadata_root();
let metadata_handle = MetadataHandle::new(root);
...

Which issue(s) this PR fixes:

Fixes #

Which docs this PR relation:

Ref #1278

Which toolchain this PR adaption:

No Breaking Change

Special notes for your reviewer:

NIL

CI Description

CI Name Description
Chaos CI Test the liveness and robustness of Axon under terrible network condition
Cargo Clippy Run cargo clippy --all --all-targets --all-features
Coverage Test Get the unit test coverage report
E2E Test Run end-to-end test to check interfaces
Code Format Run cargo +nightly fmt --all -- --check and cargo sort -gwc
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

CI Usage

Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • Chaos CI
  • Cargo Clippy
  • Coverage Test
  • E2E Tests
  • Code Format
  • Unit Tests
  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

@KaoImin KaoImin requested a review from a team as a code owner July 21, 2023 03:42
@KaoImin KaoImin requested review from jjyr and ashuralyk July 21, 2023 03:42
@KaoImin KaoImin requested review from blckngm, driftluo and yangby-cryptape and removed request for jjyr and ashuralyk July 21, 2023 03:42
@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin KaoImin changed the title refactor: thread local instead of global variable refactor(executor): thread local instead of global variable Jul 21, 2023
blckngm
blckngm previously approved these changes Jul 21, 2023
Flouse

This comment was marked as resolved.

@Flouse Flouse marked this pull request as draft July 24, 2023 03:08
@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin KaoImin marked this pull request as ready for review July 24, 2023 07:07
@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin KaoImin force-pushed the remove-system-contract-global-varible branch from e2eed10 to dff856c Compare July 24, 2023 07:12
@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@KaoImin KaoImin requested a review from blckngm July 24, 2023 07:24
blckngm
blckngm previously approved these changes Jul 25, 2023
@KaoImin

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

@yangby-cryptape

This comment was marked as off-topic.

@axon-bot

This comment was marked as outdated.

yangby-cryptape
yangby-cryptape previously approved these changes Aug 1, 2023
@Simon-Tl
Copy link
Contributor

Simon-Tl commented Aug 1, 2023

/run-ci

@axon-bot
Copy link

axon-bot bot commented Aug 1, 2023

CI tests run on commit:

CI test list:

  • Code Format
  • Cargo Clippy
  • E2E Tests
  • Unit Tests

Please check ci test results later.

driftluo
driftluo previously approved these changes Aug 2, 2023
yangby-cryptape
yangby-cryptape previously approved these changes Aug 2, 2023
Flouse
Flouse previously approved these changes Aug 2, 2023
@KaoImin KaoImin changed the title refactor(executor): thread local instead of global variable [WIP]refactor(executor): thread local instead of global variable Aug 2, 2023
@KaoImin KaoImin dismissed stale reviews from Flouse, yangby-cryptape, and driftluo via c158a57 August 2, 2023 04:34
@KaoImin KaoImin force-pushed the remove-system-contract-global-varible branch from 1381b65 to c158a57 Compare August 2, 2023 04:34
@KaoImin KaoImin changed the title [WIP]refactor(executor): thread local instead of global variable refactor(executor): thread local instead of global variable Aug 2, 2023
@KaoImin
Copy link
Contributor Author

KaoImin commented Aug 2, 2023

/run-ci

@axon-bot
Copy link

axon-bot bot commented Aug 2, 2023

CI tests run on commit:

CI test list:

  • Code Format
  • Cargo Clippy
  • E2E Tests
  • Unit Tests

Please check ci test results later.

@KaoImin KaoImin added this pull request to the merge queue Aug 2, 2023
Merged via the queue into main with commit de44cf5 Aug 2, 2023
@Flouse Flouse deleted the remove-system-contract-global-varible branch August 2, 2023 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants