Verse-Proxy Build
This is a proxy to control the access allow list of the Verse Layer.
Verse-Proxy is made by Nest.
Verse-Proxy can control following items:
- jsonrpc methods
- transaction's from, to, value
- address which can deploy smart contract
Verse Proxy Build Steps
1. Git clone
git clone git@github.com:oasysgames/verse-proxy.git
2. Set access allow list
Set the access allow list in following files.
Details are described later.
src/config/configuration.ts
src/config/transactionAllowList.ts
3. Set up npm
$ npm install
$ npm build
4. Run app
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Test
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Deploy
1. Set PORT
export PORT=[YOUR_PROXY_PORT]
2. Set allow list config
You have to download your allow list config to $PWD/src/config
.
3. Start container
# chose image version and pull image
docker pull ghcr.io/oasysgames/verse-proxy:v1.0.0
# create container
docker run --name verse-proxy -d -p $PORT:$PORT -v $PWD/src/config:/usr/src/app/src/config verse-proxy
Control items
Set allowed verse request methods
You can set allowed verse request methods through regex at src/config/configuration.ts
.
allowedMethods: [
/^net_version$/,
/^web3_clientVersion$/,
/^eth_get.*$/,
/^eth_sendRawTransaction$/,
/^eth_chainId$/,
/^eth_blockNumber$/,
/^eth_call$/,
/^eth_estimateGas$/,
/^eth_gasPrice$/,
/^eth_maxPriorityFeePerGas$/,
/^eth_feeHistory$/,
/^eth_.*Filter$/,
],
Default allowedMethods feature are following.
- It allows methods that may be requested by users
- It prohibits the methods of executing a transaction with the authority of verse-geth(e.g. eth_sendTransaction)
Set transaction allow list
You can set the allowed transaction list at src/config/transactionAllowList.ts
.
from, to
You can control the from and to of a transaction.
// elements contained in the array are allowed to be transacted.
export const getTxAllowList = (): Array<TransactionAllow> => {
return [
{
fromList: ['0xaf395754eB6F542742784cE7702940C60465A46a'],
toList: ['0xaf395754eB6F542742784cE7702940C60465A46a'],
},
{
fromList: ['0xaf395754eB6F542742784cE7702940C60465A46c'],
toList: ['0xaf395754eB6F542742784cE7702940C60465A46c'],
},
];
};
// '*' is wildcard.
export const getTxAllowList = (): Array<TransactionAllow> => {
return [
{
fromList: ['*'],
toList: ['*'],
},
];
}
// ! is denial.
// 0xaf395754eB6F542742784cE7702940C60465A46a are not allowed to be transacted.
export const getTxAllowList = (): Array<TransactionAllow> => {
return [
{
fromList: ['!0xaf395754eB6F542742784cE7702940C60465A46a'],
toList: ['!0xaf395754eB6F542742784cE7702940C60465A46a'],
},
];
};
Value
You can control the token value of a transaction.
// Only transactions with more than 1000000000000000000unit values are allowed.
export const getTxAllowList = (): Array<TransactionAllow> => {
return [
{
fromList: ['*'],
toList: ['*'],
value: { gt: '1000000000000000000' },
}
];
};
value's key | Comparison Operation |
---|---|
eq | txValue == condition is allowed |
nq | txValue != condition is allowed |
gt | txValue > condition is allowed |
gte | txValue >= condition is allowed |
lt | txValue < condition is allowed |
lte | txValue <= condition is allowed |
Deployer
You can control the deployer of a verse.
// Only 0xaf395754eB6F542742784cE7702940C60465A46a can deploy
export const getDeployAllowList = (): Array<string> => {
return ['0xaf395754eB6F542742784cE7702940C60465A46a'];
};
Set allowed header
You can set whether you inherit proxy request's host header on verse request at src/config/configuration.ts
.
inheritHostHeader: true,