Skip to content

Commit 06aaeb4

Browse files
committed
Add Movement
1 parent bb6669d commit 06aaeb4

File tree

7 files changed

+1044
-0
lines changed

7 files changed

+1044
-0
lines changed
+259
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
---
2+
slug: /movement-dev
3+
title: Getting Movement RPC
4+
---
5+
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
# Getting Movement RPC
10+
11+
## API Reference
12+
13+
<Tabs>
14+
<TabItems value="JSONRPC/HTTP" label="JSONRPC/HTTP">
15+
<Tabs>
16+
<TabItems value="cURL" label="cURL">
17+
18+
```shell
19+
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer e04c14f2-7735-4034-a458-dd1a39e75b39" https://g.w.lavanet.xyz:443/gateway/movement/rpc-http/3dc655f970c930f1d3e78ee71beece18 --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
20+
```
21+
22+
</TabItems>
23+
<TabItems value="Python" label="Python">
24+
25+
```python
26+
# pip install requests
27+
import requests
28+
import json
29+
30+
# URL for the Movement RPC HTTP endpoint
31+
url = "https://g.w.lavanet.xyz:443/gateway/movement/rpc-http/3dc655f970c930f1d3e78ee71beece18"
32+
# JSON-RPC request payload
33+
request_payload = {
34+
"jsonrpc": "2.0",
35+
"method": "eth_blockNumber",
36+
"params": [],
37+
"id": 1,
38+
}
39+
40+
try:
41+
# HTTP headers
42+
headers = {"Content-Type": "application/json"}
43+
# Sending POST request
44+
response = requests.post(url, headers=headers, data=json.dumps(request_payload))
45+
response.raise_for_status() # Check if the request was successful
46+
# Parsing JSON response
47+
data = response.json()
48+
print("Block Number Response:", data)
49+
except requests.exceptions.RequestException as e:
50+
print(f"Error fetching block number: {e}")
51+
```
52+
53+
</TabItems>
54+
<TabItems value="NodeJS" label="NodeJS">
55+
56+
```jsx
57+
//npm i axios
58+
const axios = require("axios");
59+
60+
// URL for the Movement RPC HTTP endpoint
61+
const url =
62+
"https://g.w.lavanet.xyz:443/gateway/movement/rpc-http/3dc655f970c930f1d3e78ee71beece18";
63+
// JSON-RPC request payload
64+
const requestPayload = {
65+
jsonrpc: "2.0",
66+
method: "eth_blockNumber",
67+
params: [],
68+
id: 1,
69+
};
70+
71+
async function fetchBlockNumber() {
72+
try {
73+
// Sending POST request
74+
const response = await axios.post(url, requestPayload, {
75+
headers: {
76+
"Content-Type": "application/json",
77+
},
78+
});
79+
// Logging the response
80+
console.log("Block Number Response:", response.data);
81+
} catch (error) {
82+
console.error("Error fetching block number:", error.message);
83+
}
84+
}
85+
86+
fetchBlockNumber();
87+
```
88+
89+
</TabItems>
90+
91+
</Tabs>
92+
</TabItems>
93+
<TabItems value="JSONRPC/WEBSOCKET" label="JSONRPC/WEBSOCKET">
94+
<Tabs>
95+
<TabItems value="WSCAT" label="WSCAT">
96+
97+
```shell
98+
wscat -c wss://g.w.lavanet.xyz:443/gateway/movement/rpc/3dc655f970c930f1d3e78ee71beece18 -x '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
99+
```
100+
101+
102+
</TabItems>
103+
<TabItems value="Python" label="Python">
104+
105+
```python
106+
# pip install asyncio websockets
107+
import asyncio
108+
import websockets
109+
import json
110+
111+
# WebSocket URL and JSON-RPC request payload
112+
url = "wss://g.w.lavanet.xyz:443/gateway/movement/rpc/3dc655f970c930f1d3e78ee71beece18?secret=null"
113+
request_payload = {
114+
"jsonrpc": "2.0",
115+
"method": "eth_blockNumber",
116+
"params": [],
117+
"id": 1,
118+
}
119+
120+
async def fetch_block_number():
121+
try:
122+
async with websockets.connect(url) as websocket:
123+
print("WebSocket connection opened.")
124+
# Send the JSON-RPC request payload
125+
await websocket.send(json.dumps(request_payload))
126+
127+
# Receive the response
128+
response = await websocket.recv()
129+
print("Received response:", response)
130+
except Exception as e:
131+
print("Error:", e)
132+
133+
# Run the async function
134+
asyncio.run(fetch_block_number())
135+
```
136+
137+
</TabItems>
138+
<TabItems value="NodeJS" label="NodeJS">
139+
140+
```jsx
141+
//npm i ws
142+
const WebSocket = require("ws");
143+
144+
// WebSocket URL and JSON-RPC request payload
145+
const url =
146+
"wss://g.w.lavanet.xyz:443/gateway/movement/rpc/3dc655f970c930f1d3e78ee71beece18?secret=null";
147+
const requestPayload = {
148+
jsonrpc: "2.0",
149+
method: "eth_blockNumber",
150+
params: [],
151+
id: 1,
152+
};
153+
154+
const ws = new WebSocket(url);
155+
156+
// Open the WebSocket connection
157+
ws.on("open", () => {
158+
console.log("WebSocket connection opened.");
159+
// Send the JSON-RPC request
160+
ws.send(JSON.stringify(requestPayload));
161+
});
162+
163+
// Listen for the response message
164+
ws.on("message", (message) => {
165+
console.log("Received response:", message.toString());
166+
ws.close();
167+
});
168+
169+
// Handle WebSocket errors
170+
ws.on("error", (error) => {
171+
console.error("WebSocket error:", error.message);
172+
});
173+
174+
// Handle connection closure
175+
ws.on("close", () => {
176+
console.log("WebSocket connection closed.");
177+
});
178+
```
179+
180+
</TabItems>
181+
182+
</Tabs></TabItems>
183+
184+
</Tabs>
185+
186+
<hr/>
187+
188+
## [Gateway](https://gateway.lavanet.xyz)
189+
190+
To learn more about using the Lava Gateway visit the [Getting Started guide](https://docs.lavanet.xyz/gateway-getting-started)
191+
192+
<hr />
193+
<br />
194+
195+
## SDK
196+
197+
### Input 📥
198+
199+
<Tabs>
200+
<TabItem value="backend" label="BackEnd">
201+
202+
```jsx
203+
// Install lavaSDK with the following command:
204+
// npm i @lavanet/lava-sdk
205+
const { LavaSDK } = require("@lavanet/lava-sdk");
206+
207+
async function useBeraMainnet() {
208+
const beraMainnet = await LavaSDK.create({
209+
privateKey: process.env.PRIVATE_KEY, //hide your private key in an environmental variable
210+
chainIds: "BERA",
211+
});
212+
213+
const beraBlockResponse = await beraMainnet.sendRelay({
214+
method: "eth_blockNumber",
215+
params: [],
216+
});
217+
218+
console.log(beraBlockResponse);
219+
}
220+
221+
(async () => {
222+
await useBeraMainnet();
223+
})();
224+
```
225+
226+
</TabItem>
227+
<TabItem value="frontend" label="FrontEnd">
228+
229+
```jsx
230+
// Install lavaSDK with the following command:
231+
// npm i @lavanet/lava-sdk
232+
const { LavaSDK } = require("@lavanet/lava-sdk");
233+
234+
async function useBeraMainnet() {
235+
const beraMainnet = await LavaSDK.create({
236+
badge: {
237+
badgeServerAddress: "https://badges.lavanet.xyz", // Or your own Badge-Server URL
238+
projectId: "enter_your_project_id_here",
239+
},
240+
chainIds: "BERA",
241+
});
242+
243+
const beraBlockResponse = await beraMainnet.sendRelay({
244+
method: "eth_blockNumber",
245+
params: [],
246+
});
247+
248+
console.log(beraBlockResponse);
249+
}
250+
251+
(async () => {
252+
await useBeraMainnet();
253+
})();
254+
```
255+
256+
</TabItem>
257+
</Tabs>
258+
259+
<hr />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
slug: /movement-node-bardock-archive
3+
title: Sync a Follower Node with default DB archive TESTNET
4+
---
5+
6+
# Sync a Follower Node with default DB archive "Bardock Testnet chain"
7+
8+
This guide will help you to sync an existing Bardock follower node. This procedure is only for Bardock Testnet network.
9+
If you don't have a Bardock instance setup follows the Bardock Ansible script installation of this [guide](followerNode_from_genesis.md) with this following commit: ```afddfd02d627b2a8189751950eefca3a59ddfe3b``` .
10+
11+
## Hardware Recommendations
12+
13+
To do the restoration the partition `/` should have at least 400GB of free space.
14+
15+
## Configurations files updates
16+
17+
Verify the Systemd Bardock service file: `/etc/systemd/system/movement-full-follower.service`
18+
Validate that the `CONTAINER_REV` var is correctly set as follow:
19+
20+
```Environment="CONTAINER_REV=afddfd02d627b2a8189751950eefca3a59ddfe3b"```
21+
22+
## Update the docker files
23+
24+
Go in the directory `$HOME/movement` and type:
25+
26+
```
27+
git checkout afddfd02d627b2a8189751950eefca3a59ddfe3b
28+
```
29+
30+
## Restoration script
31+
32+
The HOME directory is the directory where the `.movement` folder is located. It should be in `/home/ubuntu` or `/home/ssm-user` folder depending on your OS.
33+
In the Home directory create a new script file call `restoration.sh` and copy past this content using `nano` or `vi`:
34+
35+
```
36+
#!/bin/bash -e
37+
38+
# Stop the node if needed.
39+
systemctl stop movement-full-follower.service
40+
41+
export DOT_MOVEMENT_PATH=/home/ubuntu/.movement
42+
export CONTAINER_REV=afddfd02d627b2a8189751950eefca3a59ddfe3b
43+
export MOVEMENT_SYNC="follower::mtnet-l-sync-bucket-sync<=>{maptos,maptos-storage,suzuka-da-db}/**"
44+
export AWS_DEFAULT_REGION=us-west-1
45+
export AWS_REGION=us-west-1
46+
export MAPTOS_CHAIN_ID=250
47+
export AWS_ACCESS_KEY_ID="<access key>"
48+
export AWS_SECRET_ACCESS_KEY="<secret key>"
49+
export SYNC_PATTERN="{maptos,maptos-storage,suzuka-da-db}/**"
50+
export SYNC_BUCKET="mtnet-l-sync-bucket-sync"
51+
52+
# Restore the DB.
53+
/usr/bin/docker compose --env-file movement/.env -f ./movement/docker/compose/movement-full-node/snapshot/docker-compose.restore.yml up --force-recreate
54+
55+
# Start the node.
56+
systemctl start movement-full-follower.service
57+
```
58+
59+
Update the `<access key>` and `<secret key>` with the values from the file: `/etc/systemd/system/movement-full-follower.service`.
60+
61+
Set the script executable with: ```chmod +x restoration.sh```
62+
63+
## Start the node restoration
64+
65+
To start the node db restoration from a recent snapshot execute this command from the HOME directory:
66+
67+
```
68+
./restoration.sh
69+
```
70+
71+
The restoration should start. It can take around 1 hour depending on the speed of the hard drive and network.
72+
73+
At the end of the restoration the script will restart the node.
74+
75+
The node should sync with the leader node.
76+
77+
After a few minutes, to verify, use these commands:
78+
79+
To get the current leader Bardock state:
80+
81+
```
82+
curl https://aptos.testnet.bardock.movementlabs.xyz/v1
83+
```
84+
85+
To get your follower state:
86+
87+
```
88+
curl 127.0.0.1:30731/v1
89+
```
90+
91+
Both `ledger_version` and `block_height` state should be near or the same.
92+
93+
## Run Locally
94+
95+
To test restoration against a local node and not a real work, do the following:
96+
97+
From the initial [guide](followerNode_from_genesis.md) use this commit to checkout: ```afddfd02d627b2a8189751950eefca3a59ddfe3b``` .
98+
99+
To restore the db, you can use docker and the same `restoration.sh` script created in the `movement` directory.
100+
101+
Or use these commands in the `movement` directory:
102+
103+
```
104+
cargo build -p movement-full-node
105+
106+
DOT_MOVEMENT_PATH="$(pwd)/.movement" AWS_REGION=us-west-1 AWS_ACCESS_KEY_ID="<access key>" AWS_SECRET_ACCESS_KEY="<secret key>" target/debug/movement-full-node backup restore "mtnet-l-sync-bucket-sync" "{maptos,maptos-storage,suzuka-da-db}/**"
107+
```
108+
109+
Replace the value of access key and secret key with the one on the follower node instance.
110+
111+
After you can start the local node that should sync from the Bardock leader.

0 commit comments

Comments
 (0)