Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Figure out how to run test with rosetta-ethereum #24

Closed
3 tasks done
Tracked by #4
jimni1222 opened this issue Mar 24, 2022 · 6 comments
Closed
3 tasks done
Tracked by #4

Figure out how to run test with rosetta-ethereum #24

jimni1222 opened this issue Mar 24, 2022 · 6 comments
Assignees
Labels
subtask Sub task of task

Comments

@jimni1222
Copy link
Contributor

jimni1222 commented Mar 24, 2022

Try to run test with rosetta-ethereum.

Subtask of #4

Tasks:

  • Figure out how check:data is working.
  • Figure out how check:construction is working.
  • Figure out remaining mechanisms (reconciliation coverage under 100%, and way to generate account as recipient randomly for automating test)
    • Reconciliation coverage is calculated using the following formula. coverage = reconciledAccounts/seenAccounts.
      • So if there are 15 accounts allocated KLAY by genesis config and only 1 account is mining(meaning it get mining reward per every block and it is a balance change), then coverage result is always be 1/15 = 0.666......
    • The number at the Scenario name (e.g. transfer(10)) means concurrency level(At this concurrency level, a same scenario can be ran concurrently.).
      • And the loop condition (how many txs should be sent during test) is positioned at end_condition at config.json.
      • In the end_condition, we should provide scenario name and count(how many should we execute).
    • FindBalance
      • It searches all accounts stored in KeyStroage.
      • Call Procedure can save accounts to KeyStorage are: KeyStorage.ImportAccounts -> KeyStorage.Store and called SaveAccount workflow -> CoordinatorHelper.StoreKey -> KeyStorage.StoreTransactional.
        • KeyStorage.ImportAccounts is called when there are prefunded_accounts at config.json.
      • Conclusion: accounts scope can be searched during FindBalance is exactly limited to accounts in KeyStorage.
    • How to create random recipient address?
      • Please check the ethereum.ros at the below of this document.

Below is the contents of config.json while I'm using for testing rosetta-ethereum.

{
  "network": {
    "blockchain": "Ethereum",
    "network": "Local"
  },
  "data_directory": "cli-data",
  "http_timeout": 300,
  "max_retries": 15,
  "max_online_connections": 500,
  "max_sync_concurrency": 1,
  "tip_delay": 120,
  "compression_disabled":true,
  "memory_limit_disabled":true,
  "construction": {
    "stale_depth": 3,
    "broadcast_limit": 5,
    "clear_broadcasts": true,
    "constructor_dsl_file": "ethereum.ros",
    "prefunded_accounts": [
    {
      "privkey": "4367aeca3984c23f4d6b1b35a0edaa195d7847536f99a50a0bf178330a0ce075",
      "account_identifier": {
        "address": "0xcA7A99380131e6C76cfa622396347107aeEDCA2D"
      },
      "curve_type": "secp256k1",
      "currency": {
        "symbol": "ETH",
        "decimals": 18
      }
    },
    {
      "privkey": "051a20db11017de2eae364baa5b0828f4a559546f65a21103b0b674c62843062",
      "account_identifier": {
        "address": "0x3e2aC308cD78aC2Fe162F9522DEb2b56d9Da9499"
      },
      "curve_type": "secp256k1",
      "currency": {
        "symbol": "ETH",
        "decimals": 18
      }
    },
    {
      "privkey": "89405274a7451be9c9c769e2d9bbc876460f5bfdb8766513e0738b059dbc60e5",
      "account_identifier": {
        "address": "0xF7CCb6e6eF8386582c917604c0983D70dd555c0c"
      },
      "curve_type": "secp256k1",
      "currency": {
        "symbol": "ETH",
        "decimals": 18
      }
    },
    {
      "privkey": "a3dbf0879f13b0e81e004fab284b325d16e20bfb7bd825e11349221e3dec39b7",
      "account_identifier": {
        "address": "0xE19A5e72E8448978dbbaeE284a140f67a08aC2A4"
      },
      "curve_type": "secp256k1",
      "currency": {
        "symbol": "ETH",
        "decimals": 18
      }
    }
    ],
    "end_conditions": {
      "transfer": 1
    }
  },
  "data": {
    "initial_balance_fetch_disabled":true,
    "active_reconciliation_concurrency": 1,
    "inactive_reconciliation_concurrency": 1,
    "bootstrap_balances": "bootstrap_balances.json",
    "log_blocks": true,
    "log_transactions": true,
    "log_balance_changes": true,
    "log_reconciliations": true,
    "start_index": 1,
    "end_conditions": {
      "reconciliation_coverage": {
        "coverage": 0.5
      }
    }
  }
}

ethereum.ros for construction testing.

  • Use pre funded accounts as sender.
  • Creates random recipient.
    • use generate_key and derive function to calculate random address.
transfer(10){
  transfer{
    transfer.network = {"network":"Local", "blockchain":"Ethereum"};
    currency = {"symbol":"ETH", "decimals":18};
    sender = find_balance({
      "minimum_balance":{
        "value": "10000000000000000",
        "currency": {{currency}}
      }
    });

    // Set the recipient_amount as some value <= sender.balance-max_fee
    max_fee = "84000000000000";
    available_amount = {{sender.balance.value}} - {{max_fee}};
    recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
    print_message({"recipient_amount":{{recipient_amount}}});

    random_key = generate_key({"curve_type": "secp256k1"});
    random_recipient = derive({"network_identifier": {{transfer.network}}, "public_key": {{random_key.public_key}}});

    // Find recipient and construct operations
    sender_amount = 0 - {{recipient_amount}};
    transfer.confirmation_depth = "1";
    transfer.operations = [
      {
        "operation_identifier":{"index":0},
        "type":"CALL",
        "account":{{sender.account_identifier}},
        "amount":{
          "value":{{sender_amount}},
          "currency":{{currency}}
        }
      },
      {
        "operation_identifier":{"index":1},
        "type":"CALL",
        "account":{"address": {{random_recipient.address}}},
        "amount":{
          "value":{{recipient_amount}},
          "currency":{{currency}}
        }
      }
    ];
  }
}
@aeharvlee
Copy link
Contributor

aeharvlee commented Mar 24, 2022

I tried to understand rosetta-cli using debugging in source level, but there was a build problem.

So I created issue at rosetta-cli repo.
Issue: coinbase/mesh-cli#291

[Updated]
I switched to the latest released version v0.7.3 and it works fine.

@aeharvlee aeharvlee added the subtask Sub task of task label Mar 25, 2022
@aeharvlee
Copy link
Contributor

aeharvlee commented Mar 25, 2022

Currently following testing-with-rosetta-cli does not work.

So I'm figuring out on source code level by debugging each test execution.

[Updated]
I registered question at https://community.rosetta-api.org/t/check-data-guides-at-readme-does-not-work/715 .
Also created issue at coinbase/mesh-cli#293

cc. @jimni1222

@aeharvlee
Copy link
Contributor

I have tested both check:data and check:construction.
And you can check the result at Testing environments WIki.

@aeharvlee
Copy link
Contributor

There was an issue at recent rosseta-cli, so I created PR for that issue.

coinbase/mesh-cli#295

@jimni1222
Copy link
Contributor Author

@aeharvlee I think you need to request review for some reviewers. Seems like nobody review that now.

@aeharvlee
Copy link
Contributor

I've done remaining tasks :)
PTAL updated issue contents.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
subtask Sub task of task
Projects
None yet
Development

No branches or pull requests

2 participants