솔라나 트랜잭션 - 02

00_8_3·2022년 6월 3일
0

솔라나

목록 보기
2/5

트랜잭션

Program execution begins with a transaction being submitted to the cluster. The Solana runtime will execute a program to process each of the instructions contained in the transaction, in order, and atomically.

Program의 실행은 클러스터에 제출된 트랜잭션과 함께 시작된다.

솔라나 런타임은 각각의 instructions를 처리하기 위한 program을 실행한다.

트랜잭션 분해

이 섹션은 트랜잭션의 바이너리 포맺을 다룹니다.

트랜잭션 포맺

A transaction contains a compact-array of signatures, followed by a message. Each item in the signatures array is a digital signature of the given message. The Solana runtime verifies that the number of signatures matches the number in the first 8 bits of the message header. It also verifies that each signature was signed by the private key corresponding to the public key at the same index in the message's account addresses array.

하나의 트랜잭션은 compact-array 서명과 메시지로 구성됩니다. 서명 배열의 각각의 item은 주어진 메시지의 디지털 서명입니다.

솔라나 런타임은 메시지 헤더의 첫 8 bits이 서명의 숫자와 매치하는지 검증합니다.
또한 메시지 account 주소 배열의 동일한 인덱스의 공개키와 일치하는 개인키로 각 서명이 사인 되었는지 검증한다.

서명 포맺

Each digital signature is in the ed25519 binary format and consumes 64 bytes.

각 디지털 서명은 ed25519 바이너리 포맺이며 64 바이트이다.

https://naleejang.tistory.com/218

메시지 포맺

A message contains a header, followed by a compact-array of account addresses, followed by a recent blockhash, followed by a compact-array of instructions.

메시지는 1 헤더, 2 compact-array의 account 주소, 3 최근 blockhash
그리고 4 compact-array의 instructions로 구성된다.

메시지 헤더 포맺

The message header contains three unsigned 8-bit values. The first value is the number of required signatures in the containing transaction. The second value is the number of those corresponding account addresses that are read-only. The third value in the message header is the number of read-only account addresses not requiring signatures.

메세지 헤더는 3가지의 unsigned 8 bit 값으로 구성된다.
1. 포함하는 트랜잭션의 필수 서명 수
2. read-only인 account 주소와 일치하는 수
3. 수명을 필요로 하지 않는 read-only account 주소의 수

Account 주소 포맺

The addresses that require signatures appear at the beginning of the account address array, with addresses requesting read-write access first, and read-only accounts following. The addresses that do not require signatures follow the addresses that do, again with read-write accounts first and read-only accounts following.

서명이 필요한 주소들은 account 주소의 배열의 처음에 나타나며 읽기쓰기 액세스를 먼저 그리고 읽기전용 주소는 그다음에 나타납니다.
서명이 필요하지 않는 주소들은 서명이 필요한 주소를 따르며 읽기쓰기 account가 먼저이고 읽기 전용이 뒤따릅니다.

Blockhash Format#
A blockhash contains a 32-byte SHA-256 hash. It is used to indicate when a client last observed the ledger. Validators will reject transactions when the blockhash is too old.

Instruction Format#
An instruction contains a program id index, followed by a compact-array of account address indexes, followed by a compact-array of opaque 8-bit data. The program id index is used to identify an on-chain program that can interpret the opaque data. The program id index is an unsigned 8-bit index to an account address in the message's array of account addresses. The account address indexes are each an unsigned 8-bit index into that same array.

Compact-Array Format#
A compact-array is serialized as the array length, followed by each array item. The array length is a special multi-byte encoding called compact-u16.

Compact-u16 Format#
A compact-u16 is a multi-byte encoding of 16 bits. The first byte contains the lower 7 bits of the value in its lower 7 bits. If the value is above 0x7f, the high bit is set and the next 7 bits of the value are placed into the lower 7 bits of a second byte. If the value is above 0x3fff, the high bit is set and the remaining 2 bits of the value are placed into the lower 2 bits of a third byte.

Account Address Format#
An account address is 32-bytes of arbitrary data. When the address requires a digital signature, the runtime interprets it as the public key of an ed25519 keypair.

0개의 댓글