Skip to content

Commit 7886119

Browse files
authored
feat: update to match the newest version of rippled/witness server (#120)
## High Level Overview of Change Title says it all. ### Context of Change Title says it all. ### Type of Change - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Test Plan Tests pass locally. CI will fail because the Docker container hasn't been updated.
1 parent 05655d7 commit 7886119

File tree

6 files changed

+44
-45
lines changed

6 files changed

+44
-45
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [[Unreleased]]
9+
10+
### Changed
11+
12+
- Updated to match the latest versions of rippled and the witness server
13+
14+
## [0.1.0] - 2023-02-22
15+
16+
### Added
17+
18+
- Initial release! Please open up an issue in our repo if you have any
19+
feedback or issues to report.

xbridge_cli/bridge/register.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _signers_equal(signers1: Dict[str, Any], signers2: Dict[str, Any]) -> bool:
4949

5050
def _get_bootstrap_chain_and_door(chain_json: Dict[str, Any]) -> Tuple[str, str]:
5151
endpoint = chain_json["Endpoint"]
52-
chain = f"http://{endpoint['IP']}:{endpoint['JsonRPCPort']}"
52+
chain = f"http://{endpoint['Host']}:{endpoint['JsonRPCPort']}"
5353
door = chain_json["DoorAccount"]["Address"]
5454
return chain, door
5555

xbridge_cli/bridge/setup.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
class _UnsignedAttestation(TypedDict):
45-
xchain_bridge: XChainBridge
45+
xchain_bridge: Dict[str, Any]
4646
other_chain_source: str
4747
amount: Amount
4848
attestation_reward_account: str
@@ -57,34 +57,14 @@ class _SignedAttestation(_UnsignedAttestation):
5757
signature: str
5858

5959

60-
_ATTESTATION_ENCODE_ORDER = [
61-
("other_chain_source", 6),
62-
("amount", 2),
63-
("signature_reward", 4),
64-
("attestation_reward_account", 6),
65-
("was_locking_chain_send", 0),
66-
("xchain_account_create_count", 4),
67-
("destination", 4),
68-
]
69-
70-
7160
def _sign_attestation(
7261
attestation: _UnsignedAttestation,
73-
bridge: XChainBridge,
7462
wallet: Wallet,
7563
) -> _SignedAttestation:
76-
# TODO: use this instead once it's been implemented
77-
# attestation_xrpl = transaction_json_to_binary_codec_form(attestation)
78-
# encoded_obj = encode(attestation_xrpl)
79-
bridge_dict: Dict[str, Any] = {"xchain_bridge": bridge.to_dict()}
80-
encoded_obj = encode(transaction_json_to_binary_codec_form(bridge_dict))[4:]
81-
for key, prefix in _ATTESTATION_ENCODE_ORDER:
82-
value = attestation[key] # type: ignore # Hard to type
83-
if key == "was_locking_chain_send":
84-
encoded_obj += "0" + str(value)
85-
else:
86-
xrpl_attestation = transaction_json_to_binary_codec_form({key: value})
87-
encoded_obj += encode(xrpl_attestation)[prefix:]
64+
attestation_xrpl = transaction_json_to_binary_codec_form(
65+
cast(Dict[str, Any], attestation)
66+
)
67+
encoded_obj = encode(attestation_xrpl)
8868
signature = sign(bytes.fromhex(encoded_obj), wallet.private_key)
8969
signed_attestation: _SignedAttestation = cast(
9070
_SignedAttestation,
@@ -223,11 +203,11 @@ def setup_bridge(
223203
)
224204

225205
locking_endpoint = bootstrap_locking["Endpoint"]
226-
locking_url = f"http://{locking_endpoint['IP']}:{locking_endpoint['JsonRPCPort']}"
206+
locking_url = f"http://{locking_endpoint['Host']}:{locking_endpoint['JsonRPCPort']}"
227207
locking_client = JsonRpcClient(locking_url)
228208

229209
issuing_endpoint = bootstrap_issuing["Endpoint"]
230-
issuing_url = f"http://{issuing_endpoint['IP']}:{issuing_endpoint['JsonRPCPort']}"
210+
issuing_url = f"http://{issuing_endpoint['Host']}:{issuing_endpoint['JsonRPCPort']}"
231211
issuing_client = JsonRpcClient(issuing_url)
232212

233213
accounts_locking_check = set(
@@ -402,7 +382,7 @@ def _submit_attestation(
402382
# set up the attestations for the commit
403383
for account in accounts_issuing_check:
404384
init_attestation = _UnsignedAttestation(
405-
xchain_bridge=bridge_obj,
385+
xchain_bridge=bridge_obj.to_dict(),
406386
other_chain_source=funding_wallet.classic_address,
407387
amount=amount,
408388
attestation_reward_account=issuing_door,
@@ -412,7 +392,7 @@ def _submit_attestation(
412392
xchain_account_create_count=str(count),
413393
)
414394
signed_attestation = _sign_attestation(
415-
init_attestation, bridge_obj, issuing_door_wallet
395+
init_attestation, issuing_door_wallet
416396
)
417397
_submit_attestation(signed_attestation)
418398
count += 1

xbridge_cli/server/config/templates/bootstrap.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"LockingChain": {
33
"Endpoint": {
4-
"IP": "0.0.0.0",
4+
"Host": "0.0.0.0",
55
"JsonRPCPort": {{ locking_node_port }}
66
},
77
"DoorAccount": {
@@ -20,9 +20,9 @@
2020
"IssuingChain": {
2121
"Endpoint": {
2222
{% if is_linux %}
23-
"IP": "0.0.0.0",
23+
"Host": "0.0.0.0",
2424
{% else %}
25-
"IP": "0.0.0.0",
25+
"Host": "0.0.0.0",
2626
{% endif %}
2727
"JsonRPCPort": {{ issuing_node_port }}
2828
},

xbridge_cli/server/config/templates/witness.jinja

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"LockingChain": {
33
"Endpoint": {
44
{% if is_docker %}
5-
"IP": "192.168.176.2",
5+
"Host": "192.168.176.2",
66
{% else %}
7-
"IP": "127.0.0.1",
7+
"Host": "127.0.0.1",
88
{% endif %}
99
"Port": {{ locking_chain_port }}
1010
},
@@ -19,11 +19,11 @@
1919
"IssuingChain": {
2020
"Endpoint": {
2121
{% if is_docker %}
22-
"IP": "192.168.176.3",
22+
"Host": "192.168.176.3",
2323
{% elif is_linux %}
24-
"IP": "127.0.0.2",
24+
"Host": "127.0.0.2",
2525
{% else %}
26-
"IP": "127.0.0.1",
26+
"Host": "127.0.0.1",
2727
{% endif %}
2828
"Port": {{ issuing_chain_port }}
2929
},
@@ -37,11 +37,11 @@
3737
},
3838
"RPCEndpoint": {
3939
{% if is_docker %}
40-
"IP": "0.0.0.0",
40+
"Host": "0.0.0.0",
4141
{% elif is_linux %}
42-
"IP": "127.0.0.3",
42+
"Host": "127.0.0.3",
4343
{% else %}
44-
"IP": "127.0.0.1",
44+
"Host": "127.0.0.1",
4545
{% endif %}
4646
"Port": {{ witness_port }}
4747
},

xbridge_cli/server/start.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def start_server(
191191
_wait_for_process(
192192
process,
193193
name,
194-
config_json["RPCEndpoint"]["IP"],
194+
config_json["RPCEndpoint"]["Host"],
195195
config_json["RPCEndpoint"]["Port"],
196196
output_file,
197197
exe == "docker",
@@ -202,7 +202,7 @@ def start_server(
202202
"exe": exe,
203203
"config": config,
204204
"pid": process.pid,
205-
"http_ip": config_json["RPCEndpoint"]["IP"],
205+
"http_ip": config_json["RPCEndpoint"]["Host"],
206206
"http_port": config_json["RPCEndpoint"]["Port"],
207207
}
208208
# add witness to config file
@@ -357,7 +357,7 @@ def start_all_servers(
357357
_wait_for_process(
358358
process,
359359
name,
360-
config_json["RPCEndpoint"]["IP"],
360+
config_json["RPCEndpoint"]["Host"],
361361
config_json["RPCEndpoint"]["Port"],
362362
output_file,
363363
witnessd_exe == "docker",
@@ -369,7 +369,7 @@ def start_all_servers(
369369
"exe": "docker",
370370
"config": config,
371371
"pid": process.pid,
372-
"http_ip": config_json["RPCEndpoint"]["IP"],
372+
"http_ip": config_json["RPCEndpoint"]["Host"],
373373
"http_port": config_json["RPCEndpoint"]["Port"],
374374
}
375375
# add witness to config file

0 commit comments

Comments
 (0)