CMPSC 190N Blockchain

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

64 Terms

1
New cards

Characteristics of Bitcoin Script

stack-based, simple isntruction set, non-Turing complete, deterministic

2
New cards

Pay-to-Public-Key-Hash (P2PKH)

single signature spending requiring a private key

3
New cards

Multi-signature (Multisig)

Requires M out of N signatures for shared custody/governance

4
New cards

Pay-to-Script-Hash (P2SH)

Complex conditions through referencing a script hash

5
New cards

Zero-Knowledge proofs

verifies transaction without revealing underlying data

6
New cards

Proof of work

get reward through computing valid nonce value

7
New cards

Halving of block reward

Starting in 2008, starts at 50 btc, divides by half every 4 years. Currently at 3.125

8
New cards

Difficulty Adjustment Alg

every 2016 blocks (2 weeks at 10-minute intervals), maximum 4x change per adjustment

9
New cards

UTXO Model

stateless, new address for each transaction, high parallelization, limited scripting, simple 

10
New cards

Account Model

maintains account balances, reused addresses for transactions, limited parallelization, full programmability, complex

11
New cards

Externally Owned Accounts (EOAs)

controlled by private keys, initiates transactions, no code execution capabilities, used by human users and wallets, has nonce and balance

12
New cards

Contract Accounts

controlled by smart contract code, cannot initiate transactions, only responds to calls, contains executable bytecodes, has storage for persistent data

13
New cards

Nonce

for EOA, transaction counter preventing replay attacks

for contracts, number of contracts created

14
New cards

Balance

amount of Ether (in wei) owned by account, contracts can hold Ether

15
New cards

CodeHash

hash of the account’s code, points to executable bytecode, only for contracts

16
New cards

StorageRoot

root hash of the account’s storage trie, contains persistent data for smart contracts

17
New cards

Transfer Ether

sends ETH from one account to another

18
New cards

Call Contract Functions

executes code in existing smart contracts

19
New cards

Deploy Contracts

create new smart contracts on the network

20
New cards

to (transaction field)

Destination address or recipient

21
New cards

value (transaction field)

amount of ether to transfer

22
New cards

data (transaction field)

contract bytecode or function call data

23
New cards

gasLimit (transaction field)

maximum gas willing to spend

24
New cards

maxFeePerGas (transaction field)

maximum total fee per gas unit

25
New cards

maxPriorityFeePerGas (transaction field)

tip to minors for priority inclusion

26
New cards

Simple Transfer

to: recipient address

value: ETH amount

data: empty

27
New cards

Contract Call

to: contract address

value: ETH (optional)

data: function call

28
New cards

Contract Deployment

to: empty (null)

value: ETH (optional)

data: bytecode

29
New cards

Upfront payment of gas

gasLimit * maxFeePerGas

30
New cards

Common gas costs

basic operations (add, mul, etc.): 3-5 gas

memory operations: 3-200 gas

storage write: 20000 gas

contract creation: 32000 gas

31
New cards

Total Fee

GasUsed * (BaseFee + PriorityFee)

32
New cards

Base Fee

burned by admin to reduce ETH supply and prevent inflation

33
New cards

Priority Fee (Tip)

user-set tip to incentivize minors/validators to include the transaction quickly

34
New cards

Stack

LIFO with maximum of 1024 items, each item is max 256-bits

35
New cards

Memory

temporary byte-addressed storage that expands dynamically during execution, cleared after each call completes

36
New cards

Calldata

read-only input bytes passed to contract during transaction or call, contains function identifiers and encoded parameters, must be loaded onto stack for processing

37
New cards

Storage

persistent key value map from 256 bit keys to 256 bit values, survives after the call finishes, all slots initially zero

38
New cards

PUSH(1-16)

adds value to ith spot

39
New cards

DUP(1-16)

duplicates ith value to top

40
New cards

SWAP(1-16)

swaps top value with ith value after it

41
New cards

POP

removes top item

42
New cards

Arithmetic OPcodes (add, sub, mul, div, mod, addmod, mulmod)

256-bit modular arithmetic operations wraps at 2^256 on top two values of stack

43
New cards

Comparison opcodes (LT, GT, EQ, ISZERO)

compares top two values and produces boolean results

44
New cards

Control Flow OPcodes (JUMP, JUMPI, JUMPDEST, REVERT, STOP)

implements conditional and unconditional branching, JUMPDEST marks valid targets

45
New cards

Return OPcodes (RETURN, REVERT)

halts execution and return data (RETURN) or revert state changes (REVERT)

46
New cards

memory, storage, calldata opcodes (mload, mstore, mstore8, sload, sstore, calldataload, calldatasize, calldatacopy)

read and writes to top of stack, store expects key at top, value at 2nd, copy expects destoffset, offset, length

47
New cards

PUSH, DUP, SWAP cost

3 gas

48
New cards

POP cost

2 gas

49
New cards

ADD, SUB, MUL cost

3-5 gas

50
New cards

DIV, MOD cost

5 gas

51
New cards

LT, GT, EQ cost

3 gas

52
New cards

MLOAD, MSTORE cost

3 gas + expansion

53
New cards

SLOAD (warm) cost

100 gas

54
New cards

SLOAD (cold) cost

2100 gas

55
New cards

SSTORE (warm) cost

2900 gas

56
New cards

SSTORE (cold, new) cost

22100 gas

57
New cards

JUMP, JUMPI cost

8 gas

58
New cards

CALL cost

100+ gas (base)

59
New cards

Cold Access

first time accessing a storage slot in a transaction, first time calling a contract address, very high costs, compensates for loading data from disk

60
New cards

Warm Access

subsequent access to same slot/address, data already cached in memory, lower gas costs (than cold access), rewards batching operations

61
New cards

Read Batching

batch multiple reads from the same storage slot to reduce gas cost by turning cold reads into warm reads

62
New cards

Write Batching

accumulate changes in memory, commit once to storage, minimizes number of SSTORE operations

63
New cards

Cold to warm cost ratio

7.6x

64
New cards