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

Eth2-to-Near-relay: minor improvements, tests improvements and fixes #818

Merged
merged 56 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4def692
fix API for goerli
olga24912 Aug 30, 2022
ba1624d
fix sync committee for submitting light client update between period
olga24912 Aug 31, 2022
11e3e37
checks for empty headers submittion
olga24912 Aug 31, 2022
48c4ade
timeout on client call
olga24912 Aug 31, 2022
747738e
search for valid signature_slot
olga24912 Sep 3, 2022
2198169
arg for submit only finalized blocks
olga24912 Sep 6, 2022
381464e
:sleep 20 secs if on time
olga24912 Sep 6, 2022
f695535
skip signature slot with empty attestations
olga24912 Sep 12, 2022
fb090b4
fix don't decrement unsigned int
olga24912 Sep 12, 2022
6d9c168
sleep before new iteration
olga24912 Sep 12, 2022
fc62e3a
is_sync for beacon client
olga24912 Sep 12, 2022
0ea9087
fix after rebase
olga24912 Sep 13, 2022
ba2a295
check syncing for Eth1
olga24912 Sep 13, 2022
9679949
wait for sync
olga24912 Sep 13, 2022
c212c3e
separate timeout to config
olga24912 Sep 13, 2022
3175b40
check account id
olga24912 Sep 13, 2022
5499973
check near is sync
olga24912 Sep 13, 2022
f5a41f4
parse URL on init
olga24912 Sep 13, 2022
c9129c0
config for tests
olga24912 Sep 14, 2022
bdc1ecf
fix tests
olga24912 Sep 14, 2022
f487253
fix eth2near_relay tests
olga24912 Sep 15, 2022
fdfeebc
fix hand made finality light client updates
olga24912 Sep 16, 2022
2faaf20
execution_block_proof
olga24912 Sep 16, 2022
1afefcb
fix tests for eth1_rpc_client
olga24912 Sep 16, 2022
ea10ca6
fix beacon_rpc_client tests
olga24912 Sep 16, 2022
c1df6cf
fix: init contract by owner
olga24912 Sep 19, 2022
d22f4ab
fix tests for contract wrapper
olga24912 Sep 19, 2022
a54752b
fix tests for finality-update-verify
olga24912 Sep 19, 2022
c87c71a
rename test files
olga24912 Sep 19, 2022
feb9b28
goerli test data
olga24912 Sep 19, 2022
c9da1a3
Merge branch 'master' into eth2near-relay-configurable-tests
olga24912 Sep 19, 2022
eec2fd4
fix after merge
olga24912 Sep 19, 2022
d587352
Merge remote-tracking branch 'origin/master' into eth2near-relay-conf…
olga24912 Sep 20, 2022
6fc60eb
init contract with trust mode
olga24912 Sep 20, 2022
05ef7a0
:fix separate checks for light client update
olga24912 Sep 20, 2022
e0fd4b7
save to lfs only state files
olga24912 Sep 20, 2022
11cf954
fetch lfs objects
olga24912 Sep 20, 2022
69f677f
store test files to regular git
olga24912 Sep 20, 2022
d66b9db
ignore tests which use state files
olga24912 Sep 20, 2022
e5c6d4e
Update eth2near/eth2near-block-relay-rs/config_for_tests.toml
sept-en Sep 21, 2022
dc111e8
rename git_config -> git_test_config
olga24912 Sep 21, 2022
4e20075
change ro relay_account for signed transaction
olga24912 Sep 21, 2022
c868e9b
print finalized execution block number in slot
olga24912 Sep 21, 2022
fa247a0
secret key
olga24912 Sep 21, 2022
3e8a826
change logs order
olga24912 Sep 22, 2022
fa192e2
print info about finalized slot and number on ETH contract
olga24912 Sep 22, 2022
a17adf9
read API_KEY file in test
olga24912 Sep 22, 2022
ce4ea8d
unwrap secret key in test
olga24912 Sep 22, 2022
b859cab
Merge branch 'master' into eth2near-relay-configurable-tests
olga24912 Sep 22, 2022
ee42b47
use env for secrets
olga24912 Sep 22, 2022
cddcf73
use secret in Action
olga24912 Sep 22, 2022
d796642
Merge branch 'master' into eth2near-relay-configurable-tests
olga24912 Sep 22, 2022
8208b80
env API_KEY
olga24912 Sep 22, 2022
c02578a
Merge branch 'master' into eth2near-relay-configurable-tests
olga24912 Sep 28, 2022
fc80388
fix after merge
olga24912 Sep 28, 2022
171b5d3
API_KEY -> ETH1_INFURA_API_KEY
olga24912 Sep 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eth2near/contract_wrapper/src/dao_eth_client_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ mod tests {
finalized_beacon_header,
current_sync_committee,
next_sync_committee,
signer_account_id.clone()
);

let dao_contract_wrapper =
Expand Down
2 changes: 1 addition & 1 deletion eth2near/contract_wrapper/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ impl Display for TryToSubmitZeroHeaderError {
}
}

impl Error for TryToSubmitZeroHeaderError {}
impl Error for TryToSubmitZeroHeaderError {}
15 changes: 10 additions & 5 deletions eth2near/contract_wrapper/src/eth_client_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl EthClientContract {
finalized_beacon_header: ExtendedBeaconBlockHeader,
current_sync_committee: SyncCommittee,
next_sync_committee: SyncCommittee,
trusted_signer: String,
) {
#[derive(BorshSerialize)]
pub struct InitInput {
Expand All @@ -60,7 +61,7 @@ impl EthClientContract {
verify_bls_signatures: false,
hashes_gc_threshold: 51000,
max_submitted_blocks_by_account: 8000,
trusted_signer: Option::<AccountId>::None,
trusted_signer: Option::<AccountId>::Some(trusted_signer.parse().unwrap()),
};

self.contract_wrapper
Expand All @@ -76,6 +77,8 @@ impl EthClientContract {
pub fn get_account_id(&self) -> AccountId {
self.contract_wrapper.get_account_id()
}

pub fn get_signature_account_id(&self) -> AccountId { self.contract_wrapper.get_signer_account_id() }
}

impl EthClientContractTrait for EthClientContract {
Expand Down Expand Up @@ -194,7 +197,7 @@ mod tests {

// TODO: use a more clean approach to include binary
const WASM_FILEPATH: &str =
"../../contracts/near/target/wasm32-unknown-unknown/release/eth2_client.wasm";
"../../contracts/near/res/eth2_client.wasm";

struct EthState {
pub execution_blocks: Vec<BlockHeader>,
Expand Down Expand Up @@ -259,7 +262,6 @@ mod tests {

let worker = rt.block_on(workspaces::sandbox()).unwrap();
let wasm = std::fs::read(WASM_FILEPATH).unwrap();
let contract = rt.block_on(worker.dev_deploy(&wasm)).unwrap();

// create accounts
let owner = worker.root_account().unwrap();
Expand All @@ -274,10 +276,12 @@ mod tests {
.into_result()
.unwrap();

let contract = rt.block_on(owner.deploy(&wasm)).unwrap().unwrap();

(relay_account, contract)
}

fn init_contract(eth_client_contract: &EthClientContract, eth_state: &mut EthState) {
fn init_contract(eth_client_contract: &EthClientContract, eth_state: &mut EthState, trusted_signer: String) {
const PATH_TO_CURRENT_SYNC_COMMITTEE: &str =
"./data/next_sync_committee_kiln_period_133.json";
const PATH_TO_NEXT_SYNC_COMMITTEE: &str = "./data/next_sync_committee_kiln_period_134.json";
Expand Down Expand Up @@ -319,6 +323,7 @@ mod tests {
finalized_beacon_header,
current_sync_committee,
next_sync_committee,
trusted_signer,
);
eth_state.current_light_client_update = 1;
}
Expand All @@ -336,7 +341,7 @@ mod tests {

let mut eth_state = EthState::new();

init_contract(&eth_client_contract, &mut eth_state);
init_contract(&eth_client_contract, &mut eth_state, relay_account.id().to_string());
let first_finalized_slot = eth_client_contract
.get_finalized_beacon_block_slot()
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion eth2near/contract_wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pub mod eth_client_contract_trait;
pub mod file_eth_client_contract;
pub mod near_contract_wrapper;
pub mod sandbox_contract_wrapper;
pub mod utils;
pub mod utils;
17 changes: 2 additions & 15 deletions eth2near/eth2near-block-relay-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eth2near/eth2near-block-relay-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ reqwest = { version = "0.11", features = ["blocking"] }
eth-types = { path = "../../contracts/near/eth-types/", features = ["eip1559"]}
contract_wrapper = { path = "../contract_wrapper" }
clap = { version = "3.1.6", features = ["derive"] }
tokio = { version = "0.2", features = ["macros", "rt-threaded", "time"] }
tokio = { version = "1.1", features = ["macros", "rt", "time"] }
env_logger = "0.9.0"
borsh = "0.9.3"
near-sdk = "4.0.0"
Expand Down
23 changes: 23 additions & 0 deletions eth2near/eth2near-block-relay-rs/config_for_tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
beacon_endpoint = "https://lodestar-goerli.chainsafe.io"
eth1_endpoint = "https://goerli.infura.io/v3/64aa9edc46d941c3b30882ad2eae4304"
path_to_current_sync_committee = "./data/goerli_testdata/next_sync_committee_goerli_period_473.json"
path_to_next_sync_committee = "./data/goerli_testdata/next_sync_committee_goerli_period_474.json"
path_to_execution_blocks_headers = "./data/goerli_testdata/execution_block_headers_goerli_slots_3885697_3886176.json"
path_to_light_client_updates = "./data/goerli_testdata/light_client_updates_goerli_slots_3885697_3886176.json"
path_to_attested_state = "./data/goerli_testdata/beacon_state_goerli_slot_3885731.json"
path_to_finality_state = "./data/goerli_testdata/beacon_state_goerli_slot_3885664.json"
path_to_attested_state_for_period = "./data/goerli_testdata/beacon_state_goerli_slot_3887699.json"
path_to_finality_state_for_period = "./data/goerli_testdata/beacon_state_goerli_slot_3887616.json"
network_name = "goerli"
first_slot = 3885632
slot_without_block = 3885649
right_bound_in_slot_search = 3885800
left_empty_slot = 3885722
right_empty_slot = 3885723
slot_without_block_2 = 3885743
wasm_filepath = "../../contracts/near/res/eth2_client.wasm"
finalized_slot_before_new_period = 3891168
eth1_number = 0x73cb47
path_to_block = "./data/goerli_testdata/beacon_block_goerli_slot_3885632.json"
path_to_header = "./data/goerli_testdata/beacon_header_goerli_slot_3885632.json"
path_to_light_client_update = "./data/goerli_testdata/beacon_light_client_update_goerli_period_474.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
beacon_state_goerli_slot_3887616.json filter=lfs diff=lfs merge=lfs -text
beacon_state_goerli_slot_3887699.json filter=lfs diff=lfs merge=lfs -text
beacon_state_goerli_slot_3885664.json filter=lfs diff=lfs merge=lfs -text
beacon_state_goerli_slot_3885731.json filter=lfs diff=lfs merge=lfs -text

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":{"root":"0xa1600e330efcf934b23706365793966c4fed60d34dcdd897620810315b5abda8","canonical":true,"header":{"message":{"slot":"3885632","proposer_index":"121460","parent_root":"0x0cb13db52b63240d561b36495723229e0424fc72a25e74c02b61ae448a5f6347","state_root":"0xad73703cc94bfa83619e913bb7de2850ff08d613008a74a80df4e6977f23517c","body_root":"0x6b603cb237df9ebab0c7dc55d37ea99a2cfa381a49d220493df8f3cc3922905d"},"signature":"0x90aca2fff31ad0425a0f2a25bd92d948b5d34dfcddb15ea7fc3a7984708c70b28f531971d7b73fafd68d54ecb9e6275a0f7153c4e53c2a66b0a004338cf252e07d101e7807667bb456f38df5eff4a6b27cf1a1b51c70eb3af5297c484ad462be"}}}

Large diffs are not rendered by default.

Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading