Closed jolestar closed 11 months ago
1. SendTransaction to the sequencer and get return ordering witness response from the sequencer.
URL:
/v1/sequencer/send_tx
Method:
POST
Request:
struct {
sender_address: String,
public_key: Vec<u8>,
program: Vec<u8>,
sequencer_number: u64,
expiration_time: u64,
signature: Vec<u8>
}
Response:
struct {
transaction_hash: String,
ordering_witness: Vec<u8>
}
2. The user verifies that their transaction conforms to the order guaranteed by the sequencer.
URL:
/v1/sequencer/verify_tx
Method:
POST
Request:
struct {
transaction_hash: String,
ordering_witness: Vec<u8>
}
Response:
struct {
verify_result: Vec<u8>
}
I think we need to define the Rust trait first and design a transaction flow between components.
1. SendTransaction to the sequencer and get return order witness response from the sequencer.
URL:
/v1/sequencer/tx/send
Method:
POST
Request:
struct Request {
sender_address: String,
public_key: Vec<u8>,
program: Vec<u8>,
sequencer_number: u128,
expiration_time: u128,
signature: Vec<u8>
}
Response:
struct Response {
order: u128,
txn: String,
txn_order_signature: Vec<u8>
}
2. The user verifies that their transaction conforms to the order guaranteed by the sequencer.
URL:
/v1/sequencer/order/get_witness
Method:
GET
Request:
struct Request {
txn_hash: String,
order: u128
}
Response:
struct Response {
txn_order_witness: Vec<u8>
}
1. get user transaction
URL:
/v1/sequencer/txn/info
Method:
GET
Request:
struct Request {
txn_hash: String,
}
Response:
struct Response {
block_hash: String,
block_number: u64,
txn_hash: String,
user_txn: Vec<u8>,
conformations: u64,
}
2. get layer2 block information by number
URL:
/v1/sequencer/block/by_number
Method:
GET
Request:
struct Request {
block_number: u64,
}
Response:
struct Response {
block_hash: String,
parent_hash: String,
timestamp: u64,
number: u64,
txn_accumulator_root: String,
block_accumulator_root: String,
state_root: String,
gas_used: u64,
nonce: u64,
chain_id: u8
confirmations: u64
}
3. get layer2 block information by hash
URL:
/v1/sequencer/block/by_hash
Method:
GET
Request:
struct Request {
hash: String,
}
Response:
struct Response {
block_hash: String,
parent_hash: String,
timestamp: u64,
number: u64,
txn_accumulator_root: String,
block_accumulator_root: String,
state_root: String,
gas_used: u64,
nonce: u64,
chain_id: u8
confirmations: u64
}
4. get balance of user
URL:
/v1/sequencer/account/get_balance
Method:
GET
Request:
struct Request {
account: String,
block: Option<u128>
}
Response:
struct Response {
balance: String
}
5. get current sequence number of a account
URL:
/v1/sequencer/account/get_sequence_number
Method:
GET
Request:
struct Request {
account: String
}
Response:
struct Response {
sequence_numebr: u128
}
6. call transaction function URL:
/v1/sequencer/contract/call
Method:
POST
Request:
struct Txn {
txn_hash: String,
user_txn: Vec<u8>,
}
struct Request {
txn: Txn,
block: Option<u128>
}
Response:
struct Response {
return_data: Vec<u8>
}
7. get proof of account URL:
/v1/sequencer/account/proof
Method:
GET
Request:
struct Request {
account: String,
storage_keys: Vec<Vec<u8>>,
block: Option<u128>
}
Response:
struct Proof {
key: String,
value: String,
proof: Vec<Vec<u8>>
}
struct Response {
account: String,
account_proof: Proof,
balance: u128,
sequence_number: u128,
storage_hash: Vec<u8>,
storage_proof: Proof
}
some suggestions @steelgeek091
p.s.
In computer science, and cryptographic, using witness as proof or part of proof is common, so this word is okay. The original name "sequence proof" may conflict with "sequence" in other places.
It makes sense, I have modified the content accordingly.
Sequencer basic implementation in #158
Transaction RPC tracked by #229 Sequence Proof and RPC tracked by #228 (v0.2) Transaction storage tracked by #157
Close this issue.