You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CometBFT should support pluggable cryptographic functionality in order to allow users to address a wider range of use cases than possible with the default cryptography we provide. At present the only way they can do this is to fork the project.
Specific use cases here are to be clarified so the team understands what kinds of interface(s) to implement. Another concern potentially addressed by this is one of mitigating security-related risk through isolation of cryptography-related dependencies (probably our highest-impact dependencies) in order to make them easier to replace in case of vulnerabilities.
The first thing we need here is a design in the form of an ADR, and it must be clear from the ADR as to how the aforementioned use cases could be implemented using the design.
+1, we are currently trying to find a cleaner way to implement querying Ethereum formatted transactions on a CometBFT based chain, and the mismatch of RLP vs Sha256 makes it a requirement to store a mapping of EthHashes to CometTxHashes in some sort of off-chain database. We toyed with the idea of storing this in on chain state, but it creates a state bloat issue since these would be non-prunable.
By adding the ability to have pluggable hashes, we could ensure that these transactions would return the identical hash as to what would be created if one was processing the same transaction on Ethereum mainnet.
I had a look over PR evmos#1. I tried to understand the impact of porting those changes to CometBFT mainline.
Very much in favor of landing that upstream. Will let @melekes have a more detailed look.
Additionally, I wonder if we can reduce the amount of dependencies app <> CometBFT. Specifically, from a "beginner's mind" perspective it's concerning that CometBFT needs ability to decode transactions. I looked around the codebase and TxDecoderFn actually does not seem necessary.
There's 2 cases where CometBFT depends on TxDecoderFn in the above PR:
1/ Mempool.Ref here. I suspect we might be able to remove this dependency. Instead of CometBFT (a) decoding transactions, then (b) passing them decoded to the app for CheckTx; Comet can simply pass to the app in CheckTx raw transactions and the app itself handles decoding while handling CheckTx.
2/ BlockExecutor.Ref here. Instead of CometBFT (a) obtaining the ResponsePrepareProposal, and then (b) decoding that response; the application can be assumed to provide in ResponsePrepareProposal decoded transactions, which Comet subsequently uses to build the block.
We could get to a state where there is no need altogether for type TxDecoderFn. Also, TxI could look as follows, note only Hash seems essential from a quick glance in the codebase:
typeTxIinterface {
// EssentialHash() []byte// The tx comes in as a []byte from wire// Bytes() []byte// Needed for mempool & mempool cache// Replaceable with a basic Digest(), or with// the Hash() method above// Key() TxKey// Needed only for logging, not necessary// String() string
}
I might be missing something, but the above would likely improve dev UX. Let's clarify if these simplification are feasible and land them.
// Needed only for logging, not necessary
// String() string
The String() is necessary otherwise the hash is by default represented as uppercases, which is non-compatible with the Ethereum hash format (0x...)
Activity
itsdevbear commentedon Feb 13, 2023
+1, we are currently trying to find a cleaner way to implement querying Ethereum formatted transactions on a CometBFT based chain, and the mismatch of RLP vs Sha256 makes it a requirement to store a mapping of EthHashes to CometTxHashes in some sort of off-chain database. We toyed with the idea of storing this in on chain state, but it creates a state bloat issue since these would be non-prunable.
By adding the ability to have pluggable hashes, we could ensure that these transactions would return the identical hash as to what would be created if one was processing the same transaction on Ethereum mainnet.
JayT106 commentedon Feb 16, 2023
in the past, we had similar discussions, and ADR
tendermint/tendermint#6539
adizere commentedon Dec 6, 2023
Evmos also signalled the need for this recently. We'll likely prioritize this into v1.
1 remaining item
adizere commentedon Jan 12, 2024
I had a look over PR evmos#1. I tried to understand the impact of porting those changes to CometBFT mainline.
Very much in favor of landing that upstream. Will let @melekes have a more detailed look.
Additionally, I wonder if we can reduce the amount of dependencies app <> CometBFT. Specifically, from a "beginner's mind" perspective it's concerning that CometBFT needs ability to decode transactions. I looked around the codebase and
TxDecoderFnactually does not seem necessary.There's 2 cases where CometBFT depends on
TxDecoderFnin the above PR:1/ Mempool. Ref here. I suspect we might be able to remove this dependency. Instead of CometBFT (a) decoding transactions, then (b) passing them decoded to the app for CheckTx; Comet can simply pass to the app in CheckTx raw transactions and the app itself handles decoding while handling CheckTx.
2/ BlockExecutor. Ref here. Instead of CometBFT (a) obtaining the
ResponsePrepareProposal, and then (b) decoding that response; the application can be assumed to provide inResponsePrepareProposaldecoded transactions, which Comet subsequently uses to build the block.We could get to a state where there is no need altogether for
type TxDecoderFn. Also,TxIcould look as follows, note onlyHashseems essential from a quick glance in the codebase:I might be missing something, but the above would likely improve dev UX. Let's clarify if these simplification are feasible and land them.
feat(ADR): ADR-112: Modular transaction hashing
feat(ADR): ADR-112: Modular transaction hashing
[-]Pluggable cryptography[/-][+]ADR for modular transaction hashing[/+]fedekunze commentedon Mar 16, 2024
The
String()is necessary otherwise the hash is by default represented as uppercases, which is non-compatible with the Ethereum hash format (0x...)adizere commentedon Jun 19, 2024
Good, we'll keep it then.
docs(ADR): #113 Modular transaction hashing (#2241)