-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: move TxPoolError from fuel-core-types to fuel-core-txpool #2088
refactor: move TxPoolError from fuel-core-types to fuel-core-txpool #2088
Conversation
Will rebase on |
4b4b47b
to
287eee2
Compare
7639759
to
7f14fc2
Compare
7f14fc2
to
2cfe982
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand most of this code has been copied from a previous PR, so I apologize for the review comments changing some semantics of the display messages :)
crates/services/txpool/src/error.rs
Outdated
)] | ||
NotInsertedCollision(TxId, UtxoId), | ||
#[display( | ||
fmt = "Transaction is not inserted. More priced tx has created contract with ContractId {_0:#x}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt = "Transaction is not inserted. More priced tx has created contract with ContractId {_0:#x}" | |
fmt = "Transaction is not inserted. Higher priced tx has created contract with ContractId {_0:#x}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we also want to add the tx hash for the already spent utxo like the above error :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see, we only have ContractId
here so I believe you mistook this for the previous NotInsertedCollision
variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I've updated the message ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, I meant to ask if we should include the higher priced tx hash like we have done in other error cases, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I misunderstood you. Yeah that sounds helpful. I'll see if I can include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the txid here doesn't look trivial based on my limited understanding of the code unfortunately.
Reasoning:
This variant is only created in crates/services/txpool/src/containers/dependency.rs
in a loop that looks like this:
for output in tx.outputs() {
if let Output::ContractCreated { contract_id, .. } = output {
if let Some(contract) = self.contracts.get(contract_id) {
// we have a collision :(
if contract.is_in_database() {
return Err(Error::NotInsertedContractIdAlreadyTaken(*contract_id))
}
// check who is priced more
if contract.tip > tx.tip() {
// new tx is priced less then current tx
return Err(Error::NotInsertedCollisionContractId(*contract_id))
}
// if we are prices more, mark current contract origin for removal.
let origin = contract.origin.expect(
"Only contract without origin are the ones that are inside DB. And we check depth for that, so we are okay to just unwrap"
);
collided.push(*origin.tx_id());
}
}
// collision of other outputs is not possible.
}
The contract
variable here is of the following type
#[derive(Debug, Clone)]
pub struct ContractState {
/// is Utxo spend as other Tx input
used_by: HashSet<TxId>,
/// how deep are we inside UTXO dependency
depth: usize,
/// origin is needed for child to parent rel, in case when contract is in dependency this is how we make a chain.
origin: Option<UtxoId>,
/// gas_price. We can probably derive this from Tx
tip: Word,
}
which does not seem to hold the information about which txid created the contract.
There may be other ways to fetch the txid, but that would complect the code for what seems to be a very unusual error scenario so I'll leave this as-is for now if that's alright with you.
#[display(fmt = "The UTXO `{_0}` is blacklisted")] | ||
BlacklistedUTXO(UtxoId), | ||
#[display(fmt = "The owner `{_0}` is blacklisted")] | ||
BlacklistedOwner(Address), | ||
#[display(fmt = "The contract `{_0}` is blacklisted")] | ||
BlacklistedContract(ContractId), | ||
#[display(fmt = "The message `{_0}` is blacklisted")] | ||
BlacklistedMessage(Nonce), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a review comment, but rather a question
is this for regulatory purposes? @xgreenx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is for the case of bugs in the network that causes money printing=)
No worries, and thanks for the suggestions. This is a good opportunity to improve the messages. I'll update them. |
5133ad6
to
df129d0
Compare
…o `fuel-core-txpool`
Co-authored-by: Aaryamann Challani <43716372+rymnc@users.noreply.github.com>
cd5c113
to
33c8643
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but won't approve (in case it gets automerged) because someone with more experience with the codebase should probably sign off on it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM=)
Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
This reverts commit ed6db1b.
Linked Issues/PRs
Description
This PR does three things:
Error
type defined incrates/types/src/services/txpool.rs
is moved tocrates/services/txpool/src/error.rs
.From<WasmValidityError>
.derive_more
instead ofthiserror
for the error type.Checklist
Before requesting review