Open monkins1010 opened 1 month ago
How do we assign stuff to people in here?
I don't think I have the right permissions
The spot you circled does not have "Assign Yourself"
Also I am embarassed I did not know what a "Merkle Mountain Range" was
I got the basics for EST1 completed,
/*
Script Description:
Here we setup the basics for understand Solana Transactions,
We Create Accounts
Load them up with transactions
Get their balances
Get their transactions
Get the Slot(Block) associated with a transaction
Next Steps:
Figure out how the transactions are hashed to generate a block hash
*/
import {
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
sendAndConfirmTransaction,
SystemProgram,
Transaction,
} from "@solana/web3.js";
import * as bip39 from "bip39";
import { derivePath } from "ed25519-hd-key";
// Create HD wallet from Mnemonic
const mnemonic =
"tree panic cancel dinner tuna shaft aim jaguar quality lunar select program";
// For new mnenmonic uncomment code below
// const mnemonic = bip39.generateMnemonic()
console.log(`mnemonic = ${mnemonic}`);
const seed = bip39.mnemonicToSeedSync(mnemonic, "");
let wallets = [];
for (let i = 0; i < 10; i++) {
const path = `m/44'/501'/${i}'/0'`;
const keypair = Keypair.fromSeed(derivePath(path, seed.toString("hex")).key);
wallets.push(keypair);
console.log(`${path} => ${keypair.publicKey.toBase58()}`);
}
// Setup Solana RPC Object
const connection = new Connection("https://api.devnet.solana.com", "confirmed");
// List Balances of all Wallets
let balances = [];
for (let i = 0; i < 10; i++) {
const balance = await connection.getBalance(wallets[i].publicKey);
console.log(`${i} ${wallets[i].publicKey.toBase58()}=${balance}`);
balances.push(balance);
}
// Get transactions from wallet 0
async function waitOneSecond() {
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log("Sleept for a second to not spam RPC inerface");
}
async function getTransactionsForAddress(address, numTransactions) {
const signatures = await connection.getSignaturesForAddress(address);
console.log("Got Signatures");
// console.log(signatures);
let transactions = [];
let transactionCount = 0;
for await (const signature of signatures) {
const transaction = await connection.getTransaction(signature.signature);
transactions.push(transaction);
console.log("Got Transaction");
// console.log(transaction)
transactionCount += 1;
if (transactionCount >= numTransactions) {
console.log(`We for ${numTransactions} transactions`);
break;
}
await waitOneSecond();
}
return transactions;
}
const address = new PublicKey(wallets[0].publicKey.toBase58());
let transactions = await getTransactionsForAddress(address, 3);
// Get the block data for a one of the transactions we got
console.log(`Slot = ${transactions[0].slot}`);
let theSlot = await connection.getSlot(transactions[0].slot, {
maxSupportedTransactionVersion: 0,
});
console.log("theSlot")
console.log(theSlot)
let theBlock = await connection.getBlock(transactions[0].slot, {
maxSupportedTransactionVersion: 0,
});
console.log("theBlock")
console.log(theBlock)
// To create transactions after you load up an address,
// tranferAmount should be 0.001 by default
async function loadUpWallets(wallets, transferAmount) {
for (let i = 1; i < 10; i++) {
const transferInstruction = SystemProgram.transfer({
fromPubkey: wallets[0].publicKey,
toPubkey: wallets[i].publicKey,
lamports: transferAmount * LAMPORTS_PER_SOL, // Convert transferAmount to lamports
});
// Add the transfer instruction to a new transaction
const transaction = new Transaction().add(transferInstruction);
// Send the transaction to the network
const transactionSignature = await sendAndConfirmTransaction(
connection,
transaction,
[sender], // signer
);
console.log(
`Sent transaction ${i} for wallet ${wallets[i].publicKey.toBase58()}`,
);
}
}
A MMR is a type of merkle tree that is more efficient than a standard merkle tree, see https://docs.grin.mw/wiki/chain-state/merkle-mountain-range/
every block in verus hash a tip which is the the top of the MMR tree. The tip can be used to prove that any transaction happened on the chain at any time. So when the Verus bridge sends over a state root first to the other chain, that can be used later on once verified to be the trusted root that any transaction that is sent over is proven to along with proof.
So for EST1 we are looking for the stateroot for a block, the transaction which would contain the details of what was stored on the block, and the proof on how to get to that state root. For example on Ethereum after we store some data in a contract at a certain block cheight we call
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getProof",
"params": [
"0xe5cB067E90D5Cd1F8052B83562Ae670bA4A211a8"
]
}
and get
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"address": "0x7f0d15c7faae65896648c8273b6d7e43f58fa842",
"accountProof": [
"0xf90211a057682dd97c339167d0a923ea54273e2ecf10702b67721ad3f9dff813f2ce0205a0fdceda99d6ddafb971c700c4b834d60f651119ca5aca87fc6f1f93a50072340da04dc6877fcc14e1f3aa14a4abf6dfd3c4957d09e6bb3b440285031744c11f132da0b1db67ba601ccce18bf0c21833f1b943ecee49faa6abb53eb6d6baf2fa1d8082a039560b068a263acf368271fddb16c933521abb6e71bd571fdf2d033cdb5989d0a05c4e7aa3801447c022a9a1a3cc6353cffd5fc12a79300d29b75a1458f4678fa4a0de3f8e66a7e24847f28cf583647d7c0b90478cc2af63dba191c6cbadd90190afa0fe194f0dc6bedccce2b6465da90006cb79c030ad3a153c7d55c7c75027212f35a07d65d91165e2847c9f4a2e2807a0576f08f6ec1b6a66c78adc286f8f1b7ccceea0c2259f5449843134f1c278c770e1fa461244a76abef7b57664286820b7c16859a0c72dbc74e05bd68b032d35a5adf421f82fe4168469901c6448b8433a666cb225a0f9346c583a6ee2d0e75ce3d723d984864b7457856e661754d4ecfee0f9cdaae4a046d70957c59daa3b7df45ab746fcfb50bbae9d410ac347e34f1150bb1fd187d7a0207fb3edb0fc6dc93bdcb945362a855d51e7e0ab49d2d6f9544f07099596d930a0eeeb359a10e708f2402e82f74c145d5b4d5962ef4d2faee61ac69d2d013dd483a04cf4e8b6125c2dbc61c4d89b6c430c667478c2782290f6f724bfc9d590494b5d80",
"0xf90211a0b49c47e0d17fb4712af35919868d2e76f0cd0e73136e13d8cfe770a3bd7f451da0062f402a21167f08e4dca605f3ae7ad469771b8c2eab144ca3969a315645a74da033be642d7a3ee96cae88d3802a2095c1396118916f40d3ea7c222da96abf6bbca02c727c2053211a155eb4ff470635f490e43af9021ac3774dd552a4792072c21ea0dfb381dd62c54f3a5822c2e4deb265fe2d265b82eedb3091898e656d012f296ea0143e4a197aca20cd16d343198daa6593b70cbfbaf16e1656377d4f236c36a229a0655ad4a1dbcdb7f7d20f37b3672efab67fb47689a43bcea0664aec2f9cfc1836a0e9b7b0cd1e938547d3d9b80b84b0bd9c655cb7bea89116f9f1f3ef965e44ebefa0b4389e2a2e575012f2f9ed30ac0deb070962e09761556bcd2467d040322466c4a08644dfbab56761aee5d30f84a976a63f51241dd1328ca5bd1a2f1eaf9f443d72a04720528ec98003cb2161893e8cc80956e961aa028d0c08a4dcde7f21b49334cda0b652b1b93681ba43bda591ea314b82455b984779d36dd6b26d7b87bb1b608826a0497574f2a2fda281f5925bdcd55d66369dc57c5f1d5b0be5282454b6a433f2dea0c2823c53ccf4fcf0559e8371c511694f437a65e8d8d087a367a48e35738f0702a0e78ad0adff1f3b65bbedaf46760ccb6f18e8157f05681351f168cc62f819bbb9a066d05b1e7d4cda97dfdb6e5f025c31cc8dbc0a0cb389eb86ddc365acb7543af080",
"0xf90211a0d512f95fc80abbb3da3b08c05ae0db6ce7214801722b15a07595bd1c32cd5fd5a0110108ca5eeb72fd129bb7b325b404a88fbd2a823466c38db6da842233a812a9a0eb4ac1db947aac884d365e7521d2bae1435607394c083e9824a82f5833c568d3a01234a3ba30657a3a07b3775a07186165334963d6061deeb5753bc91c047c7d95a080cb21653a9044d643f2a91a81c3f864b8eb208dbd9f12d11669c20ce1e9fd00a09f9e31c9715cb0aaf2cfdad20675e411cad87d3cbeb6512ed0384a621337a7bca01d44535cbf77868c7fe3a193048f819ae662b039e5747e2eeb7ac294d495d98ca0a8a76b413d40f70f8d1dd99bfe99e216f18f3eae2cc2815ed05965d2c0ecd40aa0b51fb193807c7c962cc14bfde7130d3765ab56cbc2af710451453708c4cf335fa04176f9db7e358fdef66332c034f50ba351ade3697815cf462832039f2b208ac2a029305c932f739b1c5d0a421ff65f15029dd9dcd5f489d79d3728492b0ff252efa07e81446830a080dba79dd876470521cc98937e7eab43e536bfbaba0d28992bb9a003d164822ce91a4264ede7974ad779dc11e51efc3f9091353e2a846535f2d553a0b4e7d7df41afbb6198f290b1cb30ef0cd2dd52df92102edef7a9290c1a3c9159a02552e02202fdd528a47c7a112d3f75909f6f811a373e8a18f4bc2a0bd299f005a0afcc36f167e0cf6a1800bc7751a210ff483424ebb9e3c6da4b5eb99efa0db65680",
"0xf90211a04d8422d764c3762a80fef76a2eff6c21ab12894e5e2d9e04f22c06ee318ac007a0301fdd1915952b8a7bea30127074e9e2f9ac9e014ee5d8fcf6152b272b1cd728a044ddd1b7a6507910a72ecb389812ccceb1f800e059f019688cc5755b27f1438ea05e3541c5d60667aa41a91ee48b9c507552c94cc0e9c569768efdc47a8d85550ba0f881971b55026fe4603b2d5a8b1301ce67530de59313bab3118667f24f1051fda00b91d2ed1088463f8657c7efd4fd14252eb276d690337c6fe7066ef71cb76fa1a07b6c47a2d3ec219f13aec4990bbf2a3eb55ea59813280919ae56799f7e77a380a08ef2469fbc1c656755ade5d4777e25c31b964c20b75e1ab08f7aed6f4e4cbd1da062d948f3cee681c1bdb25cf4a2287fb367f5e91a63b304451a576040b967137aa04c1de96d975aef98fc5cfa4f58c007297bebab155b684b8fb9ef1b6ae5d5d443a0b278ad72680d49f110f4fd687a0c09fda2157f42abeb055299ade27b2e63eb14a004555c709d71512dfe817aa70900fa10586db2033441dc663e4aa4bdfa0d3eaba0eb73902925859ab0e85b34ab26d78983163eeb71d0551094e3360414bda40820a0055b4e96de3c7460985024bcae7e7f985dd015bd844321a0d2ad1d719469c783a0815ebee417bb8309e04073bf1a9284fcc085f01c9c2ef2eddac6a48cdccbcf12a0f90a0e448523dc51a80acfc35b384927375141477d9bf8d0c7bc0b3d2b5ea02c80",
"0xf90211a02ec53aa30b50dd55f9f8f9bf5428d596f779f2c185fd6477bfe5b4efadaae7d5a0a7a77593d8ff4aec38ed27625d5d6d14d1bf7a00ca10d562b8c8295cb5a9398ca001832c6104f429af06f56b77a90fcedb8da1f12349e8ee9a8af896947f891852a0892a46bf8f55c5f64b0af779b0aeed2b8d90755d6769726dfe13c57755d68d17a07c648d29d22d94302d05b5df82d2733fe6c5dea7eaa24623f7ec00bb95c3c18aa0eed7339a103cdde82d3bce5eb99d2a8098db1a37ea53052aa6e59112b2535d9ba066d4e48320199c41f5a9f8e680ad884f229d5a3f9e24b37d27760557f378498aa09635bc3bcb2b5ca9c434e66474f27b3d29c61132e1d48745a469c57e5b2e5442a0cf6394661bfcef70ad194cffbeddc3529a13bd447cc4a42239535cb4697eae4da0f1dd51a81c83d0e4d87ae6a2bcb4ea23a3781af95c80453e2ddb19a982bc4a6da0f33b16ced4ac6b7279ea3fc99f8f9e72b04d0348f01c983577f2f5d8d06cd313a0ef0e6a37a0605bf53bf4008f48dc6507bba802a5e26008172aad148245fea8caa0eec96c409876d9a82cd0046da97934c734ef0ef46aede447381cb3ccc9143b6ca0f85feed2292684af7f8370cd20911d583f3bd2c8b5f4b09587ff34240bafbfa7a0a461bdef60f617564d8ecad0a2c5d1f08e6e47832e4f46ad620206857c008586a0ccbea1835e26c34facad10a896aaba7dc1abb749b2ecb3870d80f324d8c88d5380",
"0xf90211a01c947f36f9da413b02ed64fb0cfd292f4e96960bf8716404c37921e26726c052a08f65c4bf233e62484513bb7c7b6e4435483442279f874d269cefeebd16d16601a051c12b25b9b33bd22f939f112cad43ac3a59e65d0a489936143f8041804a76bca001ef26f67f5ff67e0480d40e9822329c834f2683cc4973d11276c1d252c67d07a0ddbb583d588578d888365dc96e7ba8b081e4ed809368ec13336f3a6edbb4fe4ba0e8c4de149f9b385e51fb66516a4d91b62dbd80ddedd4522e14d370da47f63e5aa0a6bab2a26c167771cb857661ae7b6196b72acc111c0caab239c595c7c903a905a0911ec14c5bc5eba12f03c0ab07857899b43ce63d53f538d02675ed431d1f602ba07bc85254d84b40279df891bcdebbf5e9ed13f3cf3389f76e97ec2e5e7c3802c6a067858affaac4a665728d843114812bbec5c95ef55787ad8072bd9a5649f916aba034bfcb38403a1a9f3409ea13cb8139f820b702ee757cf87d229949825180a89ea0e3f8b04c275387c6222b6536967f2f1e6fc76dc6ee0e705d3e505f3d07e8bdd4a0deaf89533b13c20ff50ff3f03ff3a2daa8d1329a6a6d17a58c422cbe5ee2f80aa0c07ff9496c514eccb9aafdb35f908c0bf5916c8063768316d69d8a9f60a8dc02a0977297f4556485f285716435474bbf51ce270b551c7bf8e1071ff3dc57e0f545a09487a6d80521c929e599720b2e65337183f41e0b5aeb7fd2c3cfd1396510acb280",
"0xf90151a000595129cf1c67ce97ed615df7184fb47a0d018d9147a2a7952a639e464cdfd380a052081f67d885b439bee62a1c4e09c02a1ec729aef4d92be6584a29141a79c5c7a0d99cae2bc3b6fc3e8e2767b4d7a5884b9b2d9d20da7890318beefcdb9c7346d58080a0f63571735d99e763dafadb03d1abe3a93a98740ecddc8514d13df46a35a8d94680a081870f4697e57436ccdd8bdc1d624d7bc07861748ff8b3a352334df68f2c03ada0f0252504ee8753335ecf0ca1f73cf13d4505783ed5110bf4e9b384a68ad88f69a0d38a18ef7b993c9ad2d848453e7722c26998ff3d63e243b99cdab0dabf84157ea06e5ad479dbda7f1647ed613e35d837f5d2c697ef34160f3665173186553ee9c280a0bf8371cac505b6ea0cb0f67ef744713f306a2455f3f8844cfa527c62db59c69980a0d6d689405b1cf73786c5fdabb55ec22f9b5712d1ba9c0bfcd46d4b93721fcac780",
"0xf8669d37f29e142d49f8824d4e7f1735ec3da219687387629b5fccd86812df84b846f8440180a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a01d93f60f105899172f7255c030301c3af4564edd4a48577dbdc448aec7ddb0ac"
],
"balance": "0x0",
"codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"nonce": "0x0",
"storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"storageProof": [
{
"key": "0x00000000000000000000000000000000",
"value": "0x0",
"proof": []
}
]
}
}
this is a patricia trie proof of the data held in an account. we can send this to verus to prove that the transactions into our bridge contract happened, on a past block, and as verus knows how to check this proof to the state root it holds it can be sure any transactions that are sent over and match this proof can be accepted
@dentropy we need a simlar proof to the above from solana , so that when transactions occur on solana, we can send over the proofs that they happened to the stateroot of solana. and also even before the transactions and proofs are sent over we need a stateroot from the chain
https://github.com/TheFreeBishop/Verus-Solana-Bridge/blob/main/InitialResearch/Initialscope.md#est1