-
Notifications
You must be signed in to change notification settings - Fork 3.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
EthBridge storage should only be modifiable by protocol transactions #1094
EthBridge storage should only be modifiable by protocol transactions #1094
Conversation
9bbd931
to
ea88075
Compare
ac8821a
to
978ee02
Compare
pls update wasm |
1 similar comment
pls update wasm |
ea88075
to
c417cf9
Compare
6e71c65
to
f7ffd43
Compare
c417cf9
to
a48bd79
Compare
f7ffd43
to
5419ba1
Compare
pls update wasm |
54ecc2d
to
134b8b5
Compare
e967eff
to
93d1b34
Compare
8d09daa
to
d718136
Compare
134b8b5
to
d46240e
Compare
75c91bf
to
e8ae85d
Compare
pls update wasm |
de28c1b
to
d19f526
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 have a helper utility for submitting protocol transactions I can publish in another repo
@@ -61,7 +62,8 @@ pub type Result<T> = std::result::Result<T, Error>; | |||
|
|||
/// Apply a given transaction | |||
/// | |||
/// The only Tx Types that should be input here are `Decrypted` and `Wrapper` | |||
/// The only Tx Types that should be input here are `Decrypted`, `Wrapper` and |
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'm not sure about this docstring as we have a catchall case (_ =>
) which would do things for other TxTypes. I'd say we should remove this caveat from the docstring and replace the _ =>
with an explicit match arm for each TxType, then we should also get a compile error to make us update this fn if we introduced a new TxType.
|
||
/// Represents a write to a storage key | ||
#[derive(BorshDeserialize, BorshSerialize, Debug)] | ||
pub struct WriteOp { |
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.
This isn't a great location, not sure where to put it. It's a struct used in the tx_write_storage_key
test wasm, and also in the e2e tests which constructs the serialized tx.data
for a tx_write_storage_key
transaction.
use super::*; | ||
|
||
#[test] | ||
fn test_get_abs_path() { |
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.
This test runs with cargo test get_abs_path
but isn't currently running in CI
shared/src/ledger/eth_bridge/mod.rs
Outdated
"Validity predicate triggered", | ||
); | ||
let signed: Signed<Vec<u8>> = | ||
match Signed::<Vec<u8>>::try_from_slice(tx_data) { |
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.
If submitting a protocol transaction, tx_data
ends up being the tx.data
field of the innermost Tx
(i.e. the one wrapped by EthereumBridgeUpdate(Tx)
), which should be a Signed { data, sig }
if the protocol transaction is constructed correctly.
In the case of submitting a regular transaction, it seems to end up being a SignedTxData
, which I think must be the tx.data
field of the outermost Tx
that actually gets submitted to Tendermint RPC.
I haven't looked closely yet at why there is this difference, it could be just to do with the way this branch is coded currently, but the VP will reject as it can't deserialize that to a Signed
, if it gets that far.
fn log(msg: &str) { | ||
log_string(format!("[{}] {}", TX_NAME, msg)) | ||
} | ||
|
||
fn fatal(msg: &str, err: impl std::error::Error) -> ! { | ||
log(&format!("ERROR: {} - {:?}", msg, err)); | ||
panic!() | ||
} | ||
|
||
fn fatal_msg(msg: &str) -> ! { | ||
log(msg); | ||
panic!() | ||
} |
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 had to put a fair bit of logging while developing and unsure how much to remove, I guess it would add to gas cost
pls update wasm |
They're executed in a similar way to regular decrypted transactions
For now, this wasm attempts to write the transaction data to #EthBridge/queue
In the 'anoma_apps' crate, we need to make `tendermint_websocket_client` public and also re-export our tendermint crates
This is for reading "real" wasms from `wasm/` which may have their hash in their filename
Needed for working with protocol transactions (rebuilt test wasms not committed)
Needed for running our async fns in e2e tests (rebuilt test wasms not committed)
…m data Also some logging changes
Also update the existing e2e test to assert that the #EthBridge/queue storage key was not updated
0e7d200
to
e52a85d
Compare
pls update wasm |
[ci]: update wasm checksums
bbed273
to
4ed21e4
Compare
I will pick what's useful from this branch to other branch(es) since transactions to modify the Ethereum bridge may be applied internally rather than via Tendermint |
Relates to anoma/namada#114 - Depends on #1066 - this branch is based off of
james/1059/eth-bridge-vp
and this PR is targeting that branch for the time being to get a better diff.EthereumBridgeUpdate(Tx)
- and allow the wrappedTx
to be executedtx_enqueue_eth_transfer.wasm
which modifies the/queue
key under the Ethereum bridge account's storage - currently it just writes the data of the transaction directly to it, but in a future update it will manipulate the queue structure there properlyStill to come after this PR
Testing
To run end-to-end tests, assuming you already have
wasm/
s built except for the new one(s) added in this PR, run:cargo test \ eth_bridge -- \ --test-threads=1 \ --nocapture