This guide provides instructions on deploying a BVM node, with a strong recommendation to utilize Docker instead of bare-metal deployment. All instructions presented herein are tailored for the Ubuntu operating system.
Docker
Install docker will not be disscussed here. Please refer to docker official website for more details.
Change directory to veda-bvm folder and run:
docker-composeup-d
The Docker container will autonomously retrieve or build the image before executing it.
Baremental
Install python 3.9 or later is required, and simply install the package:
The Internal RPC service serves as the communication bridge connecting veda-bvm and veda-core. Alternatively, you have the option to make direct BVM calls to this service.
This internal RPC service strictly adheres to the JSON-RPC 2.0 protocol and is configured to listen on port 8679.
RPC Methods
Method
Description
Params
Return
sync
Synchronize the latest block. Returning None indicates success, returning anything else indicates failure, and the returned content is the reason for the failure.
SyncBlockModel
None or String
get_latest_block
Get latest synchronized block number
null
number
Types
SyncBlockModel
Field
Type
Description
blockHash
string
Block hash
blockNumber
number
Block number
mixHash
string
Prevrandao of the synchronizing block
timestamp
number
Timestamp of the synchronizing block
Exceptions
Type
Message Template
TypeError
Invalid parameters. Check parameter count and types. {exc}
NotImplementedError
Method not implemented: {method} {exc}
ValidationError
Validation error while executing RPC method
Internal Exception
RPC method caused exception
Examples
The file veda-bvm/scripts/tests/testinternalrpc.py provides a straightforward illustrative case that demonstrates the utilization of the internal RPC service.
This function is used to obtain the latest synchronized block number.
definternal_get_block(): jsonrpc_payload ={"id":1,"jsonrpc":"2.0","method":"get_latest_block","params": []} ret = requests.post('http://YOUR_DOCKER_IP:8679/', json=jsonrpc_payload).json()return ret
This function provides a fundamental illustration of invoking a method, such as mint within a VRC20 contract by synchronizing with a blockchain block.
definternal_rpc_simple(veda_block_number): jsonrpc_payload ={"id":1,"jsonrpc":"2.0","method":"sync","params": [{"blockHash":'0x'+'00'*31+'1f',"blockNumber": veda_block_number +1,'mixHash':'00'*31+'6f',"timestamp":123123123123}, [{'to':'TARGET_VRC20_CONTRACT_ADDRESS','sender':'0x'+'00'*19+'04','nonce':0,'txHash':'0x'+'00'*31+'04','data':'MINT_CALL_BYTECODE_HERE',} ] ]} ret = requests.post('http://YOUR_DOCKER_IP:8679/', json=jsonrpc_payload).json()return ret
By integrating the aforementioned code snippets, we obtain the following result:
ret =internal_get_block()print(ret)veda_block_number = ret['result']['veda_block_number']print('veda_block_number', veda_block_number)print(internal_rpc_simple(veda_block_number))
You can locate the logs within the ${ROOT_DIR}/logs_veda1/ directory. This is where you can access the log files.
DEBUG2024-01-0314:08:57,310InternalRPCServerSyncingblock822268DEBUG2024-01-0314:08:57,329InternalRPCServerBlock#822268-0x0000..001f contains 1 transactions, 1 succeeded, veda blockHash: 0x000000000000000000000000000000000000000000000000000000000000001fDEBUG2024-01-0314:08:57,331rpc_handlerReceivingPOSTrequest:/
If a transaction within the submitted block encounters a ValidationError, such as a bad nonce, the error will be duly logged. You may access the corresponding log entries within the 'logs-veda1/' directory as follows.
You can also perform queries on the LOG generated by the contract and invoke certain readOnly methods, such as balanceOf, associated with the contract. The contract's address is generated in accordance with Ethereum's rule: kec256(abi.encodePacked(address, nonce)).