Gas optimization in Solidity, Ethereum
I’m sorry but my English is terrible. I hope you understand that generously.Recently, I was developing a toy project named Blind Market. It’s a simple P2P trading application using smart contract. I was making a contract using Solidity, and the trade stage proceeded in the order of pending, shipping, and done. The problem was appeared in done phase. The problem was that when I tried to close the transaction by paying the price raised by the seller in msg.value, the following error occurred.Pe...
Uvicorn & Gunicorn
Uvicorn and GunicornUvicorn and Gunicorn are important concepts when developing applications in Python. However, there are many concepts to be aware of in order to fully understand Uvicorn and Gunicorn. The following is a brief summary of the necessary concepts, and the details will be dealt with separately later.Necessary ConceptsStarletteStarlette is a Web application server that can run asynchronously. Starlette runs on top of Uvicorn.FastAPIFastAPI provides many features on top of Starlet...
P2WPKH
P2WPKHP2WPKH란 비트코인 내에서 가장 일반적인 스크립트 형식으로 비트코인 프로토콜에 대한 지불 거래 유형이다. 주소는 1로 시작하는데, 세그윗을 지원하는 새로운 주소 3 또는 bc1로 시작하는 주소보다 훨씬 비싸다. https://mirror.xyz/0xA1d9f681B25C14C1eE7B87f1CF102E73cA3ad4d9/egjhNVklgy_LgZmcTXXAOTBa6ePBqO3Ja9ZSoDIad-8 즉, 비트코인 주소가 1로 시작하면 P2PKH 주소를 사용하고 있는 것이다. 공개키의 간단한 해시이며, 이 해시를 주소로 사용하는 것이다. 이것은 원래 비트코인 주소 형식이었으며 오늘까지도 충실히 작동한다. 레거시 주소는 세그윗과 호환되지 않지만, 여전히 문제없이 P2PKH 주소에서 세그윗 주소로 BTC를 보낼 수 있다. 그러나 레거시 주소 트랜잭션이 더 크기 때문에 P2PKH 주소에서 전송하는 평균 속도는 세그윗 주소에서 전송할 때보다 더 높은 요금이 발생할 수 있다....
Smart Contract Developer, Web3 Backend Developer
Gas optimization in Solidity, Ethereum
I’m sorry but my English is terrible. I hope you understand that generously.Recently, I was developing a toy project named Blind Market. It’s a simple P2P trading application using smart contract. I was making a contract using Solidity, and the trade stage proceeded in the order of pending, shipping, and done. The problem was appeared in done phase. The problem was that when I tried to close the transaction by paying the price raised by the seller in msg.value, the following error occurred.Pe...
Uvicorn & Gunicorn
Uvicorn and GunicornUvicorn and Gunicorn are important concepts when developing applications in Python. However, there are many concepts to be aware of in order to fully understand Uvicorn and Gunicorn. The following is a brief summary of the necessary concepts, and the details will be dealt with separately later.Necessary ConceptsStarletteStarlette is a Web application server that can run asynchronously. Starlette runs on top of Uvicorn.FastAPIFastAPI provides many features on top of Starlet...
P2WPKH
P2WPKHP2WPKH란 비트코인 내에서 가장 일반적인 스크립트 형식으로 비트코인 프로토콜에 대한 지불 거래 유형이다. 주소는 1로 시작하는데, 세그윗을 지원하는 새로운 주소 3 또는 bc1로 시작하는 주소보다 훨씬 비싸다. https://mirror.xyz/0xA1d9f681B25C14C1eE7B87f1CF102E73cA3ad4d9/egjhNVklgy_LgZmcTXXAOTBa6ePBqO3Ja9ZSoDIad-8 즉, 비트코인 주소가 1로 시작하면 P2PKH 주소를 사용하고 있는 것이다. 공개키의 간단한 해시이며, 이 해시를 주소로 사용하는 것이다. 이것은 원래 비트코인 주소 형식이었으며 오늘까지도 충실히 작동한다. 레거시 주소는 세그윗과 호환되지 않지만, 여전히 문제없이 P2PKH 주소에서 세그윗 주소로 BTC를 보낼 수 있다. 그러나 레거시 주소 트랜잭션이 더 크기 때문에 P2PKH 주소에서 전송하는 평균 속도는 세그윗 주소에서 전송할 때보다 더 높은 요금이 발생할 수 있다....
Smart Contract Developer, Web3 Backend Developer

Subscribe to Primrose

Subscribe to Primrose
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
Before we know about WSGI(Web Server Gateway Interface) and ASGI(Asynchronous Server Gateway Interface), we have to talk about what is CGI.
Let's say there's a server and a user. The user sends a request to the server, and the server responds.
If the user request a static page, for example, index.html, return it as it is.
But what if the request is dynamic?
What should we do when the value changes from time to time, such as log-in or requesting membership?
For that, web application runs on the server, processes certain actions (such as accessing the database) and returns html accordingly.
So we need to able to hand over requests that eventually come into the server to the web application.
At this time, it would be very inconvenient if each server or application language had different forms, so a common standard interface should be provided as much as possible.
And this interface is CGI, Common Gateway Interface.
However, this CGI has the disadvantage of having to start the application process again whenever a request is made.
This inefficiency is apparent in scripting languages such as Python because it requires more time than running programs in compiled languages such as C.
WSGI stands for Web Server Gateway Interface. It looks like a universal technique by name, but it's a concept used in Python.
The biggest drawback of CGI earlier is that it creates a new process every time a request is made.
It's a concept designed to compensate for these shortcomings.
For the CGI described earlier, the information about the request is treated as an environment variable or STDIN, but WSGI treats it as a callable object, function, or object.
When the server passes information about the request through the Callable object and the Callback function, the application processes the request and executes the Callback function.
Servers or applications that implement these interfaces are called WSGI compatible, especially in the case of applications, they are called WSGI applications.
In addition, WSGI Middleware is a kind of WSGI application that manages authentication and cookies.
This includes commonly used gunicorn, etc.
WSGI usually exposes a Python function named application or app to a web server.
This function receives two parameters:
environ : a dictionary containing information about the environment variables and current requests provided by the web server
start_response : Function used to initiate an operation that sends an HTTP response to the client
The data returned by the function constitutes the response body.
A simple application function has the following form:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b'Hello world']
If you use WSGI-compatible web framework, the framework itself provides an application function and all components of this function are automatically connected.
This WSGI had a drawback in asynchronous request processing.
It useOne synchronous callable received a request and returned a response, which was not suitable for connections that needed to be kept long(long-poll HTTP or web socket).
ASGI was created to improve this. According to ASGI's official description,
"ASGI is the spiritual successor to WSGI. Provides standard, asynchronous interfaces between Python Web servers, frameworks, and applications. If WSGI provided a standard for synchronization for Python apps, ASGI provides a standard for both synchronization and asynchronization."
ASGI is an interface that is compatible with WSGI and can handle asynchronous requests.
As an ASGI server, people usually use Uvicorn, etc.
On the surface, ASGI is similar to WSGI.
As with WSGI, it defines an application function object.
The difference is that it is an async function and has three parameters, not two.
scope : A dictionary containing the information about the current request, similar to WSGI's environ, but slightly different detailed naming conventions.
send : An async callable function that allows the application to send a message back to the client.
receive : Async callcable that allows application to receive messages from clients.
A simple application function has the following form:
async def application(scope, receive, send):
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
Like the WSGI web framework, the ASGI web framework creates its own application() function and connects as needed.
The biggest characteristic of ASGI is that it uses asynchronous metaphors across functions.
The function itself is async and sends the HTTP header and the response body in two separate await send() commands.
Therefore, the function itself and its send command do not block anything.
That is, it is possible to cross many other connections at the same time as application and send calls.
https://nitro04.blogspot.com/2020/01/django-python-asgi-wsgi-analysis-of.html
Before we know about WSGI(Web Server Gateway Interface) and ASGI(Asynchronous Server Gateway Interface), we have to talk about what is CGI.
Let's say there's a server and a user. The user sends a request to the server, and the server responds.
If the user request a static page, for example, index.html, return it as it is.
But what if the request is dynamic?
What should we do when the value changes from time to time, such as log-in or requesting membership?
For that, web application runs on the server, processes certain actions (such as accessing the database) and returns html accordingly.
So we need to able to hand over requests that eventually come into the server to the web application.
At this time, it would be very inconvenient if each server or application language had different forms, so a common standard interface should be provided as much as possible.
And this interface is CGI, Common Gateway Interface.
However, this CGI has the disadvantage of having to start the application process again whenever a request is made.
This inefficiency is apparent in scripting languages such as Python because it requires more time than running programs in compiled languages such as C.
WSGI stands for Web Server Gateway Interface. It looks like a universal technique by name, but it's a concept used in Python.
The biggest drawback of CGI earlier is that it creates a new process every time a request is made.
It's a concept designed to compensate for these shortcomings.
For the CGI described earlier, the information about the request is treated as an environment variable or STDIN, but WSGI treats it as a callable object, function, or object.
When the server passes information about the request through the Callable object and the Callback function, the application processes the request and executes the Callback function.
Servers or applications that implement these interfaces are called WSGI compatible, especially in the case of applications, they are called WSGI applications.
In addition, WSGI Middleware is a kind of WSGI application that manages authentication and cookies.
This includes commonly used gunicorn, etc.
WSGI usually exposes a Python function named application or app to a web server.
This function receives two parameters:
environ : a dictionary containing information about the environment variables and current requests provided by the web server
start_response : Function used to initiate an operation that sends an HTTP response to the client
The data returned by the function constitutes the response body.
A simple application function has the following form:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b'Hello world']
If you use WSGI-compatible web framework, the framework itself provides an application function and all components of this function are automatically connected.
This WSGI had a drawback in asynchronous request processing.
It useOne synchronous callable received a request and returned a response, which was not suitable for connections that needed to be kept long(long-poll HTTP or web socket).
ASGI was created to improve this. According to ASGI's official description,
"ASGI is the spiritual successor to WSGI. Provides standard, asynchronous interfaces between Python Web servers, frameworks, and applications. If WSGI provided a standard for synchronization for Python apps, ASGI provides a standard for both synchronization and asynchronization."
ASGI is an interface that is compatible with WSGI and can handle asynchronous requests.
As an ASGI server, people usually use Uvicorn, etc.
On the surface, ASGI is similar to WSGI.
As with WSGI, it defines an application function object.
The difference is that it is an async function and has three parameters, not two.
scope : A dictionary containing the information about the current request, similar to WSGI's environ, but slightly different detailed naming conventions.
send : An async callable function that allows the application to send a message back to the client.
receive : Async callcable that allows application to receive messages from clients.
A simple application function has the following form:
async def application(scope, receive, send):
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
Like the WSGI web framework, the ASGI web framework creates its own application() function and connects as needed.
The biggest characteristic of ASGI is that it uses asynchronous metaphors across functions.
The function itself is async and sends the HTTP header and the response body in two separate await send() commands.
Therefore, the function itself and its send command do not block anything.
That is, it is possible to cross many other connections at the same time as application and send calls.
https://nitro04.blogspot.com/2020/01/django-python-asgi-wsgi-analysis-of.html
No activity yet