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

feat(coinbase-extra): add coinbase extra field #67

Merged

Conversation

ksrichard
Copy link
Collaborator

@ksrichard ksrichard commented Sep 23, 2024

Description

Coinbase extra field is cached now (locally) and use other miners' coinbase extra when possible from share chain for their shares.

Motivation and Context

Coinbase extra field was not supported to be passed to p2pool before, so in order to let miners pass any extra data they want, we need to be able to do that.

Specs for the format of p2pool coinbase extra field: #56

How Has This Been Tested?

What process can a PR reviewer use to test or verify this change?

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify - P2pool should be updated at all clients

@ksrichard ksrichard marked this pull request as ready for review September 24, 2024 08:34
let share_chain_random_x = InMemoryShareChain::new(
MAX_BLOCKS_COUNT,
PowAlgorithm::RandomX,
Some(block_validation_params.clone()),
consensus_manager,
coinbase_extras.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be two different hashmaps

Copy link
Collaborator Author

@ksrichard ksrichard Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, makes sense let me update

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -77,6 +78,8 @@ where S: ShareChain
stats_max_difficulty_since_last_success: Arc<RwLock<Difficulty>>,
consensus_manager: ConsensusManager,
submit_block_semaphore: Arc<Semaphore>,
tribe: Tribe,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to Squad and replace all instances of tribe with Squad

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/server/grpc/util.rs Show resolved Hide resolved
let mut coinbase_extra = convert_coinbase_extra(tribe.clone(), String::new()).unwrap_or_default();
if let Ok(miner_wallet_address) = TariAddress::from_str(key.as_str()) {
if let Some(coinbase_extra_found) =
self.find_coinbase_extra(bl.levels.iter(), miner_wallet_address).await
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is O(n^2) and will be slow, I think find a better way of doing this without iterating through all the levels

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally makes sense, let me refactor

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay just pushed!
I removed the unneeded iteration, just using the provided coinbase cache and update there the values when adding new blocks to share chain.

@stringhandler stringhandler merged commit 0139691 into tari-project:development Sep 24, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants