Ethereum uses RPC
install MIPS based Linux header file
$CD $prjroot / kernel
$tar - xjvf linux-2.6.38. Tar. Bz2
$CD linux-2.6.38
create an include folder under the specified path to store related header files< br />$ mkdir -p $TARGET_ Prefix / include
ensures that the Linux source code is clean
$make mrproper
generates the required header file< br />$ make ARCH=mips headers_ check
$ make ARCH=mips INSTALL_ HDR_ PATH=dest headers_ Install
all the files in dest folder to the specified include folder< br />$ cp -rv dest/include/* $TARGET_ Prefix / include
delete dest folder at last
$RM - RF dest
$LS - L $target_ PREFIX/include
If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records
the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:
< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />}); Pre >
Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query
recommend a practical introction, you can see: Ethereum tutorial
we can separate RPC framework into four layers: RPC physical communication layer,
RPC communication protocol layer, RPC connection session layer and RPC application layer< A. RPC physical communication layer, according to the actual use can choose the appropriate physical communication protocol:
1)< It can use UDP network communication protocol, but it is necessary to maintain the data packet timing, packet loss retransmission, to
and virtual connection status. Although using UDP is relatively troublesome, UDP also has many advantages,
such as relatively easy NAT penetration, complete data per packet and so on< SHM shared memory communication can be used for RPC calls between different processes on the same host, with the advantages of fast transmission speed and the disadvantages of only running on the same host< The third-party communication mole interface can be used, such as Bluetooth, serial port, USB connection interface, etc. The advantage is that it can
call each other across terminal devices, and the disadvantage is that it is subject to the third-party communication mole interface
B. the RPC communication protocol layer is the message packet definition of both sides of communication and the data organization of each message. It only needs to be responsible for the data flow of sending and receiving. The physical communication layer is responsible for how to send and receive data
1). Message packet = & lt; Header & gt; +[ That is to say, a message packet is composed of a message header and a message body< The message header must contain: message package ID, message type, message body length, function ID and call return code< However, the size of the header should not be too large,
otherwise, the call cost of RPC will be greater< There are at least the following message types:
A) heartbeat, including request and response
b) connection handshake, including request and response
C)
d). Log out of the application, including request and response
e). Get the definition set, including request and response, that is, read the function definition set of the logged in application< Call function, including request and response
G). Function cancellation means to cancel the submitted function call request
H)
I). Send data to extend RPC to packet communication< The RPC connection session layer is responsible for the connection state management of both sides of the communication, including the following aspects:
1)
2)< The function definition set provided by the opposite application can be obtained by logging in to the application. The function can be called only when the parameter and return value of the function are known. The function definition is the precondition of serialization / deserialization of the parameter and return value
4)
5)
6). It manages the buffer queue of sending packets and the processing of receiving packets
D. the RPC application layer is responsible for the function definition in the application, managing the login and logout of the connection, and allocating the function call request
1). In the function definition, the data types of function parameters and return values should be enough. Different data types can be
to facilitate data display and increase the flexibility of RPC framework. At the same time, the
type of function callback called by RPC should support multiple calling methods, which can be applied to more development languages
2). The function call request can only be accepted after the connection logs in to the application. When the connection logs out of the application, all the function call requests of this
connection will be cancelled automatically
3). The application needs to manage the running thread to execute the allocated function call request.
关于RPC 路由器的实现主要分布在smd_rpcrouter.c、smd_rpcrouter_device.c、smd_rpcrouter_servers.c、smd_rpcrouter_clients.c等文件中RPC路由器起着RPC服务器查询、RPC服务器和RPC客户端的注册和销毁,以及底层通信的封装功能,类似于TCP协议
在实际的实现中,RPC路由器和RPC服务器均是作为一个虚拟的字符型设备来存在的
下面是RPC路由器的创建过程:
代码3-11 RPC 路由器的创建过程
int msm_rpcrouter_init_devices(void)
{
int rc;
int major;
msm_rpcrouter_class=class_create(THIS_MODULE,
"oncrpc"); //创建设备节点
if (IS_ERR(msm_rpcrouter_class)) {
rc=-ENOMEM;
printk(KERN_ERR
"rpcrouter: failed to create oncrpc class ");
goto fail;
}
rc=alloc_chrdev_region(&msm_rpcrouter_devno,
0, //作为字符型设备分配资源
RPCROUTER_MAX_REMOTE_SERVERS + 1, "oncrpc");
if (rc<0) {
printk(KERN_ERR
"rpcrouter: Failed to alloc chardev region (%d) ", rc);
goto fail_destroy_class;
}
major=MAJOR(msm_rpcrouter_devno);
rpcrouter_device=device_create(msm_
rpcrouter_class, NULL, //创建设备
msm_rpcrouter_devno, NULL, "%.8x:%d",
0, 0);
if (IS_ERR(rpcrouter_device)) {
rc=-ENOMEM;
goto fail_unregister_cdev_region;
}
cdev_init(&rpcrouter_cdev, &rpcrouter_
router_fops); //字符型设备初始化
rpcrouter_cdev.owner=THIS_MODULE;
rc=cdev_add(&rpcrouter_cdev, msm_rpcrouter_devno, 1);
if (rc<0)
goto fail_destroy_device;
return 0;
fail_destroy_device:
device_destroy(msm_rpcrouter_class,
msm_rpcrouter_devno);//销毁设备
fail_unregister_cdev_region:
unregister_chrdev_region(msm_rpcrouter_devno, //去注册
RPCROUTER_MAX_REMOTE_SERVERS + 1);
fail_destroy_class:
class_destroy(msm_rpcrouter_class);
fail:
return rc;
}
method 1: modify the registry method
click "start → run", type "regedit" to open the "Registry Editor", and expand the branch "HKEY"_ LOCAL_ MACHINE\ SYSTEM\ CurrentControlSet\ Services\ Method 2: use the sc.exe command
click "start → run", type "CMD" to enter the "command prompt" window, type "SC config RPCs start = Auto" command, and the system will display "[SC] changeserviceconfig success", This enables the RPC service to start successfully
note: if you want to use the "SC" command, you must install the windows 2000 / 2003 Resource Kit (Resource Kit), otherwise it is invalid to use this command
method 3: use the recovery console
take Windows XP system as an example, put the installation CD in the CD-ROM drive, and set the BIOS parameters to boot from CD-ROM; After starting the computer, the system will enter the Windows XP installation interface, press the "R" key to log in to the recovery console. In the recovery console, type "enable RPCs service"_ auto_ After that, you can restart the system and log in in the normal mode to start the RPC service successfully
note: "enable" is a command provided by the recovery console to start system services and device drivers. It can only be used in the recovery console
SC command
"SC" command is a command provided by Windows 2000 resource kit to communicate with system services, and "SC config" is one of its subcommands, which is used to modify service items in the configuration registry or service database. The command format is as follows:
SC < server > config [service name] < option1 > < option2 >...
parameter options: start = < boot system auto demand disabled >
where "server" is the name of the server, which is used on the local machine. This option can be omitted, and the command is executed on the local machine by default“ The parameter options of "start" include "boot, system, auto, demand and disabled", and the latter three correspond to "automatic, manual and disabled".
there is a flaw in the part of RPC dealing with message exchange over TCP / IP. Incorrectly handling malformed messages can cause errors. This particular error affects the underlying DCOM interface, which listens on TCP / IP port 135. By sending a malformed RPC message, an attacker can cause a problem with the RPC service on a computer, and then enable arbitrary code to be executed
remote procere call (RPC) is a protocol used by Windows operating system. RPC provides an interprocess communication mechanism, through which programs running on a computer can smoothly execute the code on a remote system. The protocol itself is derived from OSF (Open Software Foundation) RPC Protocol, only adding some Microsoft specific extensions
there is a vulnerability in the part of RPC that handles message exchange over TCP / IP. This problem is caused by incorrect handling of malformed messages. This particular vulnerability affects an interface between distributed component object model (DCOM) and RPC that listens on TCP / IP port 135. This interface handles DCOM object activation requests (such as universal naming convention (UNC) paths) sent by client computers to servers
to exploit this vulnerability, an attacker may need to send a special format request to port 135 on a remote computer<
mitigating factors:
to exploit this vulnerability, an attacker may need to have the ability to send a crafted request to port 135 on a remote computer. For Intranet environment, this port is usually accessible; But for computers connected through Internet, firewall usually blocks port 135. If the port is not blocked, or in an intranet environment, the attacker does not need any other privileges
the best practice is to block all actually unused TCP / IP ports. Therefore, most computers connected to the Internet should block port 135. RPC over TCP is not suitable for use in dangerous environment such as Internet. More robust protocols like RPC over HTTP are suitable for potentially dangerous environments
this is a buffer overflow vulnerability. An attacker who successfully exploits this vulnerability may gain full control of the remote computer. This may allow an attacker to perform arbitrary operations on the server, including changing the web page, reformatting the hard disk, or adding new users to the local Administrators group
to launch such an attack, an attacker needs to be able to send a malformed message to the RPC service, thus causing the target computer to be controlled by others, and the attacker can execute arbitrary code on it
the best way to prevent remote RPC attacks from the Internet is to configure the firewall to block port 135. RPC over TCP is not suitable for use in dangerous environment such as Internet
this vulnerability is caused by the failure of windows RPC service to check message input correctly in some cases. If an attacker sends some type of RPC message with incorrect format after establishing a connection with RPC, it will cause problems in the basic distributed component object model (DCOM) interface between the remote computer and RPC, and then enable arbitrary code to be executed.
Click & quot; Start → run & quot;, Type & quot; Regedit" Open & quot; Registry Editor & quot;, Expand branch & quot; HKEY_ LOCAL_ MACHINE\ SYSTEM\ CurrentControlSet\ Services\ RpcSs", Change the value of the start item to & quot; 00000002", Just restart the system
method 2: use the sc.exe command
Click & quot; Start → run & quot;, Type & quot; cmd" Enter & quot; Command prompt & quot; Window, type & quot; sc config RpcSs start= auto" Command, the system will display & quot;
1) service provider, running on the server, provides service interface definition and service implementation class
2) service center, running on the server, is responsible for publishing local services to remote services, managing remote services, and providing them to service consumers
3) the service consumer runs on the client and calls the remote service through the remote proxy object.