From d9f823a3366f9cb18b848f1652cb2c890c09338c Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 14 Nov 2024 21:12:12 -0500 Subject: [PATCH 01/53] feat: evm inflation --- eth-genesis.json | 61 ++++++++++++++++ eth-nether-genesis.json | 97 ++++++++++++++++++++++++++ mod/chain-spec/pkg/chain/chain_spec.go | 27 +++++++ mod/chain-spec/pkg/chain/data.go | 11 ++- 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 eth-genesis.json create mode 100644 eth-nether-genesis.json diff --git a/eth-genesis.json b/eth-genesis.json new file mode 100644 index 0000000000..c70530febd --- /dev/null +++ b/eth-genesis.json @@ -0,0 +1,61 @@ +{ + "config": { + "chainId": 80000, + "homesteadBlock": 0, + "daoForkBlock": 0, + "daoForkSupport": true, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "arrowGlacierBlock": 0, + "grayGlacierBlock": 0, + "mergeNetsplitBlock": 0, + "shanghaiTime": 0, + "cancunTime": 0, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true, + "ethash": { + + } + }, + "alloc": { + "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B": { + "balance": "0x1f972880" + }, + "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500" + }, + "0x4e59b44847b379578588920cA78FbF26c0B4956C": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" + }, + "0x4242424242424242424242424242424242424242": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610abf575080632dfdf0b514610a7b578063560036ec1461094d578063577212fe1461087d5780639eaffa96146107f7578063c53925d914610618578063e12cf4cb1461020b5763fea7ab7714610074575f80fd5b346102075760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576100c3903690600401610b7b565b9060243573ffffffffffffffffffffffffffffffffffffffff81168082036102075773ffffffffffffffffffffffffffffffffffffffff6040518585823760208187810160018152030190205416938433036101df5781156101b7577f7640ec3c8c4695deadda414dd20400acf275297a7c38715f9237657e97ddba5f93606093604051838382376020818581016002815203019020907fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006bffffffffffffffffffffffff421691871b1617905581604051928392833781015f8152039020936040519182526020820152426040820152a2005b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f7c214f04000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f80fd5b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610255903690600401610b7b565b9060243567ffffffffffffffff811161020757610276903690600401610b7b565b60449391933567ffffffffffffffff811161020757610299903690600401610b7b565b5f9291925060643573ffffffffffffffffffffffffffffffffffffffff811680910361020757603085036105f057602083036105c857606082036105a05773ffffffffffffffffffffffffffffffffffffffff6040518688823760208188810160018152030190205416155f1461057357801561054b57604051858782376020818781016001815203019020817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb1740360405186888237808781015f8152039020916040519081525f602082015260408180030190a25b633b9aca00340661052357633b9aca00340467ffffffffffffffff81116104fb575f38818034815af1156104ee5767ffffffffffffffff169064077359400082106104c6575f549367ffffffffffffffff85169467ffffffffffffffff8614610499577f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d469861048e9561047b927fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000067ffffffffffffffff60018b01169116175f5561046d6040519a8b9a60a08c5260a08c0191610ba9565b9189830360208b0152610ba9565b9260408701528583036060870152610ba9565b9060808301520390a1005b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f0e1eddda000000000000000000000000000000000000000000000000000000005f5260045ffd5b63b12d13eb5f526004601cfd5b7f2aa66734000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f40567b38000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f51969a7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b15610395577fc4142b41000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4be6321b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fb39bca16000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f106472000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610667903690600401610b7b565b604051818382376020818381016002815203019020548060601c908133036107cf576bffffffffffffffffffffffff620151809116016bffffffffffffffffffffffff8111610499576bffffffffffffffffffffffff8042169116116107a7577f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb174039173ffffffffffffffffffffffffffffffffffffffff60405182868237602081848101600181520301902054169360405182828237602081848101600181520301902073ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790555f6040518383823760208185810160028152030190205581604051928392833781015f815203902092604051918252602082015260408180030190a2005b7fe8966d7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f819a0d0b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff81116102075773ffffffffffffffffffffffffffffffffffffffff602061085e81933690600401610b7b565b9190826040519384928337810160018152030190205416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576108cc903690600401610b7b565b9073ffffffffffffffffffffffffffffffffffffffff604051838382376020818581016001815203019020541633036101df575f6040518383823760208185810160028152030190205581604051928392833781015f81520390207f1c0a7e1bd09da292425c039309671a03de56b89a0858598aab6df6ce84b006db5f80a2005b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757366023820112156102075780600401359067ffffffffffffffff8211610a4e57604051907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f81601f8601160116820182811067ffffffffffffffff821117610a4e5760405282825260208201913660248584010111610207575f60208560409660248396018737830101528351928391518091835e81016002815203019020548151906bffffffffffffffffffffffff8116825260601c6020820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610207575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757602067ffffffffffffffff5f5416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361020757817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115610b51575b5015158152f35b7f136f920d0000000000000000000000000000000000000000000000000000000091501483610b4a565b9181601f840112156102075782359167ffffffffffffffff8311610207576020838186019501011161020757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f858286010152011601019056fea164736f6c634300081a000a" + }, + "0x6969696969696969696969696969696969696969": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x60806040526004361015610022575b3615610018575f80fd5b610020610a14565b005b5f3560e01c806306fdde03146108fb578063095ea7b31461087257806318160ddd1461082f57806323b872dd146107285780632e1a7d4d1461064f578063313ce567146106165780633644e5151461054c57806370a08231146104fc5780637ecebe00146104ac57806395d89b41146103f5578063a9059cbb14610348578063d0e30db014610317578063d505accf146101205763dd62ed3e0361000e573461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576100f76109aa565b6100ff6109cd565b602052637f5e9f20600c525f5260206034600c2054604051908152f35b5f80fd5b3461011c5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576101576109aa565b61015f6109cd565b6084359160643560443560ff8516850361011c5761017b6109f0565b60208101907f577261707065642042657261000000000000000000000000000000000000000082525190209082421161030a5773ffffffffffffffffffffffffffffffffffffffff80604051951695169565383775081901600e52855f5260c06020600c20958654957f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252602082019586528660408301967fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc688528b6060850198468a528c608087019330855260a08820602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9885252528688525260a082015220604e526042602c205f5260ff1660205260a43560405260c43560605260208060805f60015afa93853d51036102fd577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259460209401905585777f5e9f200000000000000000000000000000000000000000176040526034602c2055a3005b63ddafbaef5f526004601cfd5b631a15a3cc5f526004601cfd5b5f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57610020610a14565b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761037f6109aa565b602435906387a211a2600c52335f526020600c2080548084116103e85783900390555f526020600c20818154019055602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b63f4d678b85f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57604051604081019080821067ffffffffffffffff83111761047f5761047b91604052600581527f5742455241000000000000000000000000000000000000000000000000000000602082015260405191829182610962565b0390f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576104e36109aa565b6338377508600c525f52602080600c2054604051908152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576105336109aa565b6387a211a2600c525f52602080600c2054604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060a06105866109f0565b828101907f57726170706564204265726100000000000000000000000000000000000000008252519020604051907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015220604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060405160128152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576004356387a211a2600c52335f526020600c20908154918282116103e857815f93039055806805345cdf77eb68f44c54036805345cdf77eb68f44c5580825281337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a3808252337f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65602084a281803892335af11561071b57005b63b12d13eb5f526004601cfd5b3461011c5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761075f6109aa565b6107676109cd565b604435908260601b33602052637f5e9f208117600c526034600c20908154916001830161080b575b506387a211a2915017600c526020600c2080548084116103e85783900390555f526020600c2081815401905560205273ffffffffffffffffffffffffffffffffffffffff600c5160601c91167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b82851161082257846387a211a2930390558561078f565b6313be252b5f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5760206805345cdf77eb68f44c54604051908152f35b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576108a96109aa565b60243590602052637f5e9f20600c52335f52806034600c20555f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa3602060405160018152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761047b6109346109f0565b7f57726170706564204265726100000000000000000000000000000000000000006020820152604051918291825b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060409481855280519182918282880152018686015e5f8582860101520116010190565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b604051906040820182811067ffffffffffffffff82111761047f57604052600c8252565b6805345cdf77eb68f44c54348101908110610aa5576805345cdf77eb68f44c556387a211a2600c52335f526020600c2034815401905534602052600c5160601c5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3345f52337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c60205fa2565b63e5cfe9575f526004601cfdfea164736f6c634300081a000a" + } + }, + "coinbase": "0x0000000000000000000000000000000000000000", + "difficulty": "0x01", + "extraData": "", + "gasLimit": "0x1c9c380", + "nonce": "0x1234", + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "timestamp": "TODO: SET TIMESTAMP" +} diff --git a/eth-nether-genesis.json b/eth-nether-genesis.json new file mode 100644 index 0000000000..fd5dbe1bce --- /dev/null +++ b/eth-nether-genesis.json @@ -0,0 +1,97 @@ +{ + "name": "cArtio", + "engine": { + "Ethash": { + + } + }, + "params": { + "gasLimitBoundDivisor": "0x400", + "registrar": "0x0000000000000000000000000000000000000000", + "accountStartNonce": "0x0", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1c9c380", + "networkID": "0x13880", + "MergeForkIdTransition": "0x0", + "maxCodeSize": "0x6000", + "maxCodeSizeTransition": "0x0", + "eip150Transition": "0x0", + "eip158Transition": "0x0", + "eip160Transition": "0x0", + "eip161abcTransition": "0x0", + "eip161dTransition": "0x0", + "eip155Transition": "0x0", + "eip140Transition": "0x0", + "eip211Transition": "0x0", + "eip214Transition": "0x0", + "eip658Transition": "0x0", + "eip145Transition": "0x0", + "eip1014Transition": "0x0", + "eip1052Transition": "0x0", + "eip1283Transition": "0x0", + "eip1283DisableTransition": "0x0", + "eip152Transition": "0x0", + "eip1108Transition": "0x0", + "eip1344Transition": "0x0", + "eip1884Transition": "0x0", + "eip2028Transition": "0x0", + "eip2200Transition": "0x0", + "eip2565Transition": "0x0", + "eip2929Transition": "0x0", + "eip2930Transition": "0x0", + "eip1559Transition": "0x0", + "eip3198Transition": "0x0", + "eip3529Transition": "0x0", + "eip3541Transition": "0x0", + "eip4895TransitionTimestamp": "0x0", + "eip3855TransitionTimestamp": "0x0", + "eip3651TransitionTimestamp": "0x0", + "eip3860TransitionTimestamp": "0x0", + "eip1153TransitionTimestamp": "0x0", + "eip4844TransitionTimestamp": "0x0", + "eip4788TransitionTimestamp": "0x0", + "eip5656TransitionTimestamp": "0x0", + "eip6780TransitionTimestamp": "0x0", + "terminalTotalDifficulty": "0x0" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x1234", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x01", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "TODO: SET TIMESTAMP (HEX)", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "", + "gasLimit": "0x1c9c380" + }, + "accounts": { + "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B": { + "balance": "0x1f972880" + }, + "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500" + }, + "0x4e59b44847b379578588920cA78FbF26c0B4956C": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" + }, + "0x4242424242424242424242424242424242424242": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610abf575080632dfdf0b514610a7b578063560036ec1461094d578063577212fe1461087d5780639eaffa96146107f7578063c53925d914610618578063e12cf4cb1461020b5763fea7ab7714610074575f80fd5b346102075760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576100c3903690600401610b7b565b9060243573ffffffffffffffffffffffffffffffffffffffff81168082036102075773ffffffffffffffffffffffffffffffffffffffff6040518585823760208187810160018152030190205416938433036101df5781156101b7577f7640ec3c8c4695deadda414dd20400acf275297a7c38715f9237657e97ddba5f93606093604051838382376020818581016002815203019020907fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006bffffffffffffffffffffffff421691871b1617905581604051928392833781015f8152039020936040519182526020820152426040820152a2005b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f7c214f04000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f80fd5b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610255903690600401610b7b565b9060243567ffffffffffffffff811161020757610276903690600401610b7b565b60449391933567ffffffffffffffff811161020757610299903690600401610b7b565b5f9291925060643573ffffffffffffffffffffffffffffffffffffffff811680910361020757603085036105f057602083036105c857606082036105a05773ffffffffffffffffffffffffffffffffffffffff6040518688823760208188810160018152030190205416155f1461057357801561054b57604051858782376020818781016001815203019020817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb1740360405186888237808781015f8152039020916040519081525f602082015260408180030190a25b633b9aca00340661052357633b9aca00340467ffffffffffffffff81116104fb575f38818034815af1156104ee5767ffffffffffffffff169064077359400082106104c6575f549367ffffffffffffffff85169467ffffffffffffffff8614610499577f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d469861048e9561047b927fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000067ffffffffffffffff60018b01169116175f5561046d6040519a8b9a60a08c5260a08c0191610ba9565b9189830360208b0152610ba9565b9260408701528583036060870152610ba9565b9060808301520390a1005b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f0e1eddda000000000000000000000000000000000000000000000000000000005f5260045ffd5b63b12d13eb5f526004601cfd5b7f2aa66734000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f40567b38000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f51969a7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b15610395577fc4142b41000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4be6321b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fb39bca16000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f106472000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610667903690600401610b7b565b604051818382376020818381016002815203019020548060601c908133036107cf576bffffffffffffffffffffffff620151809116016bffffffffffffffffffffffff8111610499576bffffffffffffffffffffffff8042169116116107a7577f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb174039173ffffffffffffffffffffffffffffffffffffffff60405182868237602081848101600181520301902054169360405182828237602081848101600181520301902073ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790555f6040518383823760208185810160028152030190205581604051928392833781015f815203902092604051918252602082015260408180030190a2005b7fe8966d7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f819a0d0b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff81116102075773ffffffffffffffffffffffffffffffffffffffff602061085e81933690600401610b7b565b9190826040519384928337810160018152030190205416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576108cc903690600401610b7b565b9073ffffffffffffffffffffffffffffffffffffffff604051838382376020818581016001815203019020541633036101df575f6040518383823760208185810160028152030190205581604051928392833781015f81520390207f1c0a7e1bd09da292425c039309671a03de56b89a0858598aab6df6ce84b006db5f80a2005b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757366023820112156102075780600401359067ffffffffffffffff8211610a4e57604051907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f81601f8601160116820182811067ffffffffffffffff821117610a4e5760405282825260208201913660248584010111610207575f60208560409660248396018737830101528351928391518091835e81016002815203019020548151906bffffffffffffffffffffffff8116825260601c6020820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610207575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757602067ffffffffffffffff5f5416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361020757817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115610b51575b5015158152f35b7f136f920d0000000000000000000000000000000000000000000000000000000091501483610b4a565b9181601f840112156102075782359167ffffffffffffffff8311610207576020838186019501011161020757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f858286010152011601019056fea164736f6c634300081a000a" + }, + "0x6969696969696969696969696969696969696969": { + "balance": "0x0", + "nonce": "0x1", + "code": "0x60806040526004361015610022575b3615610018575f80fd5b610020610a14565b005b5f3560e01c806306fdde03146108fb578063095ea7b31461087257806318160ddd1461082f57806323b872dd146107285780632e1a7d4d1461064f578063313ce567146106165780633644e5151461054c57806370a08231146104fc5780637ecebe00146104ac57806395d89b41146103f5578063a9059cbb14610348578063d0e30db014610317578063d505accf146101205763dd62ed3e0361000e573461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576100f76109aa565b6100ff6109cd565b602052637f5e9f20600c525f5260206034600c2054604051908152f35b5f80fd5b3461011c5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576101576109aa565b61015f6109cd565b6084359160643560443560ff8516850361011c5761017b6109f0565b60208101907f577261707065642042657261000000000000000000000000000000000000000082525190209082421161030a5773ffffffffffffffffffffffffffffffffffffffff80604051951695169565383775081901600e52855f5260c06020600c20958654957f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252602082019586528660408301967fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc688528b6060850198468a528c608087019330855260a08820602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9885252528688525260a082015220604e526042602c205f5260ff1660205260a43560405260c43560605260208060805f60015afa93853d51036102fd577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259460209401905585777f5e9f200000000000000000000000000000000000000000176040526034602c2055a3005b63ddafbaef5f526004601cfd5b631a15a3cc5f526004601cfd5b5f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57610020610a14565b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761037f6109aa565b602435906387a211a2600c52335f526020600c2080548084116103e85783900390555f526020600c20818154019055602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b63f4d678b85f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57604051604081019080821067ffffffffffffffff83111761047f5761047b91604052600581527f5742455241000000000000000000000000000000000000000000000000000000602082015260405191829182610962565b0390f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576104e36109aa565b6338377508600c525f52602080600c2054604051908152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576105336109aa565b6387a211a2600c525f52602080600c2054604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060a06105866109f0565b828101907f57726170706564204265726100000000000000000000000000000000000000008252519020604051907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015220604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060405160128152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576004356387a211a2600c52335f526020600c20908154918282116103e857815f93039055806805345cdf77eb68f44c54036805345cdf77eb68f44c5580825281337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a3808252337f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65602084a281803892335af11561071b57005b63b12d13eb5f526004601cfd5b3461011c5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761075f6109aa565b6107676109cd565b604435908260601b33602052637f5e9f208117600c526034600c20908154916001830161080b575b506387a211a2915017600c526020600c2080548084116103e85783900390555f526020600c2081815401905560205273ffffffffffffffffffffffffffffffffffffffff600c5160601c91167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b82851161082257846387a211a2930390558561078f565b6313be252b5f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5760206805345cdf77eb68f44c54604051908152f35b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576108a96109aa565b60243590602052637f5e9f20600c52335f52806034600c20555f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa3602060405160018152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761047b6109346109f0565b7f57726170706564204265726100000000000000000000000000000000000000006020820152604051918291825b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060409481855280519182918282880152018686015e5f8582860101520116010190565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b604051906040820182811067ffffffffffffffff82111761047f57604052600c8252565b6805345cdf77eb68f44c54348101908110610aa5576805345cdf77eb68f44c556387a211a2600c52335f526020600c2034815401905534602052600c5160601c5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3345f52337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c60205fa2565b63e5cfe9575f526004601cfdfea164736f6c634300081a000a" + } + }, + "nodes": [] +} diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index 5d65f45e2c..f0d207660c 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -183,6 +183,17 @@ type Spec[ // GetCometBFTConfigForSlot retrieves the CometBFT config for a specific // slot. GetCometBFTConfigForSlot(slot SlotT) CometBFTConfigT + + // Berachain Values + + // EVMInflationAddress returns the address on the EVM which will receive + // the inflation amount of native EVM balance through a withdrawal every + // block. + EVMInflationAddress() ExecutionAddressT + + // EVMInflationPerBlock returns the amount of native EVM balance to be + // minted to the EVMInflationAddress via a withdrawal every block. + EVMInflationPerBlock() uint64 } // chainSpec is a concrete implementation of the ChainSpec interface, holding @@ -476,3 +487,19 @@ func (c chainSpec[ ]) GetCometBFTConfigForSlot(_ SlotT) CometBFTConfigT { return c.Data.CometValues } + +// EVMInflationAddress returns the address on the EVM which will receive the +// inflation amount of native EVM balance through a withdrawal every block. +func (c chainSpec[ + DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, +]) EVMInflationAddress() ExecutionAddressT { + return c.Data.EVMInflationAddress +} + +// EVMInflationPerBlock returns the amount of native EVM balance to be minted to +// the EVMInflationAddress via a withdrawal every block. +func (c chainSpec[ + DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, +]) EVMInflationPerBlock() uint64 { + return c.Data.EVMInflationPerBlock +} diff --git a/mod/chain-spec/pkg/chain/data.go b/mod/chain-spec/pkg/chain/data.go index 3c3ae2a637..2a780a87e4 100644 --- a/mod/chain-spec/pkg/chain/data.go +++ b/mod/chain-spec/pkg/chain/data.go @@ -144,6 +144,15 @@ type SpecData[ // KZGCommitmentInclusionProofDepth is the depth of the KZG inclusion proof. KZGCommitmentInclusionProofDepth uint64 `mapstructure:"kzg-commitment-inclusion-proof-depth"` - // CometValues + // Comet Values CometValues CometBFTConfigT `mapstructure:"comet-bft-config"` + + // Berachain Values + // + // EVMInflationAddress is the address on the EVM which will receive the + // inflation amount of native EVM balance through a withdrawal every block. + EVMInflationAddress ExecutionAddressT `mapstructure:"evm-inflation-address"` + // EVMInflationPerBlock is the amount of native EVM balance to be minted + // to the EVMInflationAddress via a withdrawal every block. + EVMInflationPerBlock uint64 `mapstructure:"evm-inflation-per-block"` } From c0a78e4611c0383ef73bdceb026c4f5b4532ca35 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 14:09:27 -0500 Subject: [PATCH 02/53] nits --- mod/state-transition/pkg/core/state_processor_staking.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index c161d32864..6c6404ea8c 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -274,7 +274,7 @@ func (sp *StateProcessor[ } } - // Update the next withdrawal index if this block contained withdrawals + // Update the next withdrawal index if this block contained withdrawals. if numWithdrawals != 0 { // Next sweep starts after the latest withdrawal's validator index if err = st.SetNextWithdrawalIndex( @@ -289,16 +289,16 @@ func (sp *StateProcessor[ return err } - // Update the next validator index to start the next withdrawal sweep + // Update the next validator index to start the next withdrawal sweep. //#nosec:G701 // won't overflow in practice. if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { - // Next sweep starts after the latest withdrawal's validator index + // Next sweep starts after the latest withdrawal's validator index. nextValidatorIndex = (expectedWithdrawals[len(expectedWithdrawals)-1].GetIndex() + 1) % math.U64(totalValidators) } else { // Advance sweep by the max length of the sweep if there was not - // a full set of withdrawals + // a full set of withdrawals. nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() if err != nil { return err From 0ad632955a85f29fd6f0cfe06485af1f05d21baa Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 15:38:39 -0500 Subject: [PATCH 03/53] more --- mod/chain-spec/go.mod | 13 +++- mod/chain-spec/go.sum | 59 ++++++++++++++++++- mod/chain-spec/pkg/chain/chain_spec.go | 19 +++++- mod/chain-spec/pkg/chain/errors.go | 31 ++++++++++ mod/chain-spec/pkg/chain/helpers_test.go | 5 +- mod/config/pkg/spec/betnet.go | 4 +- mod/config/pkg/spec/boonet.go | 4 +- mod/config/pkg/spec/devnet.go | 4 +- mod/config/pkg/spec/testnet.go | 4 +- mod/node-core/pkg/components/chain_spec.go | 21 +++---- mod/primitives/pkg/common/execution.go | 6 ++ mod/state-transition/pkg/core/errors.go | 10 ++++ .../pkg/core/state/statedb.go | 25 +++++--- .../pkg/core/state_processor_genesis_test.go | 6 +- .../pkg/core/state_processor_staking.go | 57 ++++++++++++------ .../pkg/core/state_processor_staking_test.go | 3 +- 16 files changed, 215 insertions(+), 56 deletions(-) create mode 100644 mod/chain-spec/pkg/chain/errors.go diff --git a/mod/chain-spec/go.mod b/mod/chain-spec/go.mod index ee6ebc0169..7ed953b767 100644 --- a/mod/chain-spec/go.mod +++ b/mod/chain-spec/go.mod @@ -3,13 +3,24 @@ module github.com/berachain/beacon-kit/mod/chain-spec go 1.23.0 require ( + github.com/berachain/beacon-kit/mod/errors v0.0.0-20240610210054-bfdc14c4013c github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240911165923-82f71ec86570 github.com/stretchr/testify v1.9.0 ) require ( + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/getsentry/sentry-go v0.28.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/mod/chain-spec/go.sum b/mod/chain-spec/go.sum index 5f2efaee22..53f19deb43 100644 --- a/mod/chain-spec/go.sum +++ b/mod/chain-spec/go.sum @@ -1,20 +1,73 @@ +github.com/berachain/beacon-kit/mod/errors v0.0.0-20240610210054-bfdc14c4013c h1:rPoD2zVkIzuMC4R/XMuwx6eanJL8ccu37sLro+eIj3Y= +github.com/berachain/beacon-kit/mod/errors v0.0.0-20240610210054-bfdc14c4013c/go.mod h1:xgngH5/PYbyW+YDEmRhbBy3V333GXsNWF4DAkjYCmfs= github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240911165923-82f71ec86570 h1:w0Gkg31VQRFDv0EJjYgVtlpza7kSaJq7U28zxZjfZeE= github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240911165923-82f71ec86570/go.mod h1:Mrq1qol8vbkgZp2IMPFwngg75qE3k9IvT2MouBEhuus= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k= +github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index f0d207660c..37139e28ed 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -218,14 +218,27 @@ func NewChainSpec[ CometBFTConfigT any, ](data SpecData[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, -]) Spec[ +]) (Spec[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, -] { - return &chainSpec[ +], error) { + c := &chainSpec[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, ]{ Data: data, } + return c, c.validate() +} + +// validate ensures that the chain spec is valid, returning error if it is not. +func (c *chainSpec[ + DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, +]) validate() error { + if c.MaxWithdrawalsPerPayload() == 0 { + return ErrZeroMaxWithdrawalsPerPayload + } + + // TODO: Add more validation rules here. + return nil } // MinDepositAmount returns the minimum deposit amount required. diff --git a/mod/chain-spec/pkg/chain/errors.go b/mod/chain-spec/pkg/chain/errors.go new file mode 100644 index 0000000000..e99c2cf162 --- /dev/null +++ b/mod/chain-spec/pkg/chain/errors.go @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package chain + +import "github.com/berachain/beacon-kit/mod/errors" + +var ( + // ErrZeroMaxWithdrawalsPerPayload is returned when the max withdrawals + // per payload is zero. Must allow at least one for the EVM inflation + // withdrawal. + ErrZeroMaxWithdrawalsPerPayload = errors.New( + "max withdrawals per payload must be greater than 0") +) diff --git a/mod/chain-spec/pkg/chain/helpers_test.go b/mod/chain-spec/pkg/chain/helpers_test.go index d0d97a5b62..767f6ae8dd 100644 --- a/mod/chain-spec/pkg/chain/helpers_test.go +++ b/mod/chain-spec/pkg/chain/helpers_test.go @@ -37,8 +37,10 @@ type ( cometBFTConfig struct{} ) +// TODO: Add setupValid, setupInvalid functions and use in each test. + // Create an instance of chainSpec with test data. -var spec = chain.NewChainSpec( +var spec, _ = chain.NewChainSpec( chain.SpecData[ domainType, epoch, executionAddress, slot, cometBFTConfig, ]{ @@ -46,6 +48,7 @@ var spec = chain.NewChainSpec( ElectraForkEpoch: 10, SlotsPerEpoch: 32, MinEpochsForBlobsSidecarsRequest: 5, + MaxWithdrawalsPerPayload: 1, }, ) diff --git a/mod/config/pkg/spec/betnet.go b/mod/config/pkg/spec/betnet.go index edaef1254c..289b663ca6 100644 --- a/mod/config/pkg/spec/betnet.go +++ b/mod/config/pkg/spec/betnet.go @@ -27,13 +27,13 @@ import ( ) // BetnetChainSpec is the ChainSpec for the localnet. -func BetnetChainSpec() chain.Spec[ +func BetnetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, common.ExecutionAddress, math.Slot, any, -] { +], error) { testnetSpec := BaseSpec() testnetSpec.DepositEth1ChainID = BetnetEth1ChainID return chain.NewChainSpec(testnetSpec) diff --git a/mod/config/pkg/spec/boonet.go b/mod/config/pkg/spec/boonet.go index 83213baba2..36fe46083e 100644 --- a/mod/config/pkg/spec/boonet.go +++ b/mod/config/pkg/spec/boonet.go @@ -27,13 +27,13 @@ import ( ) // BoonetChainSpec is the ChainSpec for the localnet. -func BoonetChainSpec() chain.Spec[ +func BoonetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, common.ExecutionAddress, math.Slot, any, -] { +], error) { testnetSpec := BaseSpec() testnetSpec.DepositEth1ChainID = BoonetEth1ChainID return chain.NewChainSpec(testnetSpec) diff --git a/mod/config/pkg/spec/devnet.go b/mod/config/pkg/spec/devnet.go index 9e189b1d83..6b13acac17 100644 --- a/mod/config/pkg/spec/devnet.go +++ b/mod/config/pkg/spec/devnet.go @@ -27,13 +27,13 @@ import ( ) // DevnetChainSpec is the ChainSpec for the localnet. -func DevnetChainSpec() chain.Spec[ +func DevnetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, common.ExecutionAddress, math.Slot, any, -] { +], error) { testnetSpec := BaseSpec() testnetSpec.DepositEth1ChainID = DevnetEth1ChainID return chain.NewChainSpec(testnetSpec) diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index a9d2970506..6455b4759e 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -29,13 +29,13 @@ import ( ) // TestnetChainSpec is the ChainSpec for the localnet. -func TestnetChainSpec() chain.Spec[ +func TestnetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, common.ExecutionAddress, math.Slot, any, -] { +], error) { testnetSpec := BaseSpec() testnetSpec.DepositEth1ChainID = TestnetEth1ChainID return chain.NewChainSpec(testnetSpec) diff --git a/mod/node-core/pkg/components/chain_spec.go b/mod/node-core/pkg/components/chain_spec.go index c70bb3b9fa..4f2b7a85aa 100644 --- a/mod/node-core/pkg/components/chain_spec.go +++ b/mod/node-core/pkg/components/chain_spec.go @@ -35,21 +35,22 @@ const ( ) // ProvideChainSpec provides the chain spec based on the environment variable. -func ProvideChainSpec() common.ChainSpec { +func ProvideChainSpec() (common.ChainSpec, error) { // TODO: This is hood as fuck needs to be improved // but for now we ball to get CI unblocked. - specType := os.Getenv(ChainSpecTypeEnvVar) - var chainSpec common.ChainSpec - switch specType { + var ( + chainSpec common.ChainSpec + err error + ) + switch os.Getenv(ChainSpecTypeEnvVar) { case DevnetChainSpecType: - chainSpec = spec.DevnetChainSpec() + chainSpec, err = spec.DevnetChainSpec() case BetnetChainSpecType: - chainSpec = spec.BetnetChainSpec() + chainSpec, err = spec.BetnetChainSpec() case BoonetChainSpecType: - chainSpec = spec.BoonetChainSpec() + chainSpec, err = spec.BoonetChainSpec() default: - chainSpec = spec.TestnetChainSpec() + chainSpec, err = spec.TestnetChainSpec() } - - return chainSpec + return chainSpec, err } diff --git a/mod/primitives/pkg/common/execution.go b/mod/primitives/pkg/common/execution.go index 3addc635fb..ece76afa56 100644 --- a/mod/primitives/pkg/common/execution.go +++ b/mod/primitives/pkg/common/execution.go @@ -21,6 +21,7 @@ package common import ( + "bytes" "encoding" "github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/hex" @@ -97,6 +98,11 @@ func NewExecutionAddressFromHex(input string) ExecutionAddress { return ExecutionAddress(hex.MustToBytes(input)) } +// Equals returns true if the two addresses are the same. +func (a ExecutionAddress) Equals(other ExecutionAddress) bool { + return bytes.Equal(a[:], other[:]) +} + // Hex converts an address to a hex string. func (a ExecutionAddress) Hex() string { return string(a.checksumHex()) } diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index a0e2160ac8..f973a8865b 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -80,4 +80,14 @@ var ( // ErrNumWithdrawalsMismatch is returned when the number of withdrawals // in a block does not match the expected value. ErrNumWithdrawalsMismatch = errors.New("number of withdrawals mismatch") + + // ErrNoWithdrawals is returned when a block contains no withdrawals. We + // expect at least the fixed withdrawal for EVM inflation. + ErrNoWithdrawals = errors.New( + "no withdrawals in block, expected at least 1 for EVM inflation") + + // ErrFirstWithdrawalNotEVMInflation is returned when the first withdrawal + // in the block is not the EVM inflation withdrawal. + ErrFirstWithdrawalNotEVMInflation = errors.New( + "first withdrawal is not the EVM inflation withdrawal") ) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 830ad7e310..e49e79be4a 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -187,6 +187,9 @@ func (s *StateDB[ // ExpectedWithdrawals as defined in the Ethereum 2.0 Specification: // https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-get_expected_withdrawals // +// NOTE: This function is modified from the spec to allow a fixed withdrawal +// (as the first withdrawal) used for EVM inflation. +// //nolint:lll func (s *StateDB[ _, _, _, _, _, _, ValidatorT, _, WithdrawalT, _, @@ -196,8 +199,17 @@ func (s *StateDB[ balance math.Gwei withdrawalAddress common.ExecutionAddress withdrawals = make([]WithdrawalT, 0) + withdrawal WithdrawalT ) + // The first withdrawal is fixed to be the EVM inflation withdrawal. + // + // NOTE: The withdrawal index and validator index are both set to 0 as they + // are not used during processing. + withdrawals = append(withdrawals, withdrawal.New( + 0, 0, s.cs.EVMInflationAddress(), math.U64(s.cs.EVMInflationPerBlock()), + )) + slot, err := s.GetSlot() if err != nil { return nil, err @@ -226,6 +238,11 @@ func (s *StateDB[ // Iterate through indices to find the next validators to withdraw. for range bound { + // Cap the number of withdrawals to the maximum allowed per payload. + if uint64(len(withdrawals)) == s.cs.MaxWithdrawalsPerPayload() { + break + } + validator, err = s.ValidatorByIndex(validatorIndex) if err != nil { return nil, err @@ -244,8 +261,6 @@ func (s *StateDB[ // Set the amount of the withdrawal depending on the balance of the // validator. - var withdrawal WithdrawalT - //nolint:gocritic // ok. if validator.IsFullyWithdrawable(balance, epoch) { withdrawals = append(withdrawals, withdrawal.New( @@ -283,12 +298,6 @@ func (s *StateDB[ withdrawalIndex++ } - // Cap the number of withdrawals to the maximum allowed per payload. - //#nosec:G701 // won't overflow in practice. - if len(withdrawals) == int(s.cs.MaxWithdrawalsPerPayload()) { - break - } - // Increment the validator index to process the next validator. validatorIndex = (validatorIndex + 1) % math.ValidatorIndex( totalValidators, diff --git a/mod/state-transition/pkg/core/state_processor_genesis_test.go b/mod/state-transition/pkg/core/state_processor_genesis_test.go index 95a88c0272..79ee13281f 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis_test.go +++ b/mod/state-transition/pkg/core/state_processor_genesis_test.go @@ -40,7 +40,8 @@ import ( func TestInitialize(t *testing.T) { // Create state processor to test - cs := spec.BetnetChainSpec() + cs, err := spec.BetnetChainSpec() + require.NoError(t, err) execEngine := mocks.NewExecutionEngine[ *types.ExecutionPayload, *types.ExecutionPayloadHeader, @@ -161,7 +162,8 @@ func checkValidatorNonBartio( func TestInitializeBartio(t *testing.T) { // Create state processor to test - cs := spec.TestnetChainSpec() + cs, err := spec.TestnetChainSpec() + require.NoError(t, err) execEngine := mocks.NewExecutionEngine[ *types.ExecutionPayload, *types.ExecutionPayloadHeader, diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 6c6404ea8c..177d26dd4a 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -225,6 +225,9 @@ func (sp *StateProcessor[ // processWithdrawals as per the Ethereum 2.0 specification. // https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-process_withdrawals // +// NOTE: This function is modified from the spec to allow a fixed withdrawal +// (must be the first withdrawal) used for EVM inflation. +// //nolint:lll func (sp *StateProcessor[ _, BeaconBlockBodyT, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, @@ -232,9 +235,7 @@ func (sp *StateProcessor[ st BeaconStateT, body BeaconBlockBodyT, ) error { - // Dequeue and verify the logs. var ( - nextValidatorIndex math.ValidatorIndex payload = body.GetExecutionPayload() payloadWithdrawals = payload.GetWithdrawals() ) @@ -246,7 +247,7 @@ func (sp *StateProcessor[ } numWithdrawals := len(expectedWithdrawals) - // Ensure the withdrawals have the same length + // Ensure the expected and payload withdrawals have the same length. if numWithdrawals != len(payloadWithdrawals) { return errors.Wrapf( ErrNumWithdrawalsMismatch, @@ -255,6 +256,19 @@ func (sp *StateProcessor[ ) } + // Ensure the EVM inflation withdrawal is the first withdrawal. + if numWithdrawals == 0 { + return ErrNoWithdrawals + } + if !expectedWithdrawals[0].GetAddress().Equals( + sp.cs.EVMInflationAddress(), + ) || + expectedWithdrawals[0].GetAmount() != math.U64( + sp.cs.EVMInflationPerBlock(), + ) { + return ErrFirstWithdrawalNotEVMInflation + } + // Compare and process each withdrawal. for i, wd := range expectedWithdrawals { // Ensure the withdrawals match the local state. @@ -266,7 +280,13 @@ func (sp *StateProcessor[ ) } - // Then we process the withdrawal. + // The first withdrawal is the EVM inflation withdrawal. No processing + // is needed. + if i == 0 { + continue + } + + // Process the validator withdrawal. if err = st.DecreaseBalance( wd.GetValidatorIndex(), wd.GetAmount(), ); err != nil { @@ -274,9 +294,10 @@ func (sp *StateProcessor[ } } - // Update the next withdrawal index if this block contained withdrawals. - if numWithdrawals != 0 { - // Next sweep starts after the latest withdrawal's validator index + // Update the next withdrawal index if this block contained withdrawals + // (excluding the EVM inflation withdrawal). + if numWithdrawals > 1 { + // Next sweep starts after the latest withdrawal's validator index. if err = st.SetNextWithdrawalIndex( (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), ); err != nil { @@ -290,23 +311,21 @@ func (sp *StateProcessor[ } // Update the next validator index to start the next withdrawal sweep. - //#nosec:G701 // won't overflow in practice. - if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { + var nextValIndex math.ValidatorIndex + if numWithdrawals > 1 && + uint64(numWithdrawals) == sp.cs.MaxWithdrawalsPerPayload() { // Next sweep starts after the latest withdrawal's validator index. - nextValidatorIndex = - (expectedWithdrawals[len(expectedWithdrawals)-1].GetIndex() + 1) % - math.U64(totalValidators) + nextValIndex = expectedWithdrawals[numWithdrawals-1].GetIndex() + 1 } else { - // Advance sweep by the max length of the sweep if there was not - // a full set of withdrawals. - nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() + // Advance sweep by the max length of the sweep if there was not a full + // set of withdrawals. + nextValIndex, err = st.GetNextWithdrawalValidatorIndex() if err != nil { return err } - nextValidatorIndex += math.ValidatorIndex( - sp.cs.MaxValidatorsPerWithdrawalsSweep()) - nextValidatorIndex %= math.ValidatorIndex(totalValidators) + nextValIndex += math.U64(sp.cs.MaxValidatorsPerWithdrawalsSweep()) } + nextValIndex %= math.U64(totalValidators) - return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) + return st.SetNextWithdrawalValidatorIndex(nextValIndex) } diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 8ed6c99b9c..6c5884f3ac 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -39,7 +39,8 @@ import ( func TestTransitionUpdateValidators(t *testing.T) { // Create state processor to test - cs := spec.BetnetChainSpec() + cs, err := spec.BetnetChainSpec() + require.NoError(t, err) execEngine := mocks.NewExecutionEngine[ *types.ExecutionPayload, *types.ExecutionPayloadHeader, From fb1177c91131468b154984e625ea6d2c8553d982 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 15:47:38 -0500 Subject: [PATCH 04/53] delete unneeded --- eth-genesis.json | 61 -------------- eth-nether-genesis.json | 97 ---------------------- mod/da/pkg/store/pruner_test.go | 4 +- mod/node-core/pkg/components/dispatcher.go | 4 +- 4 files changed, 6 insertions(+), 160 deletions(-) delete mode 100644 eth-genesis.json delete mode 100644 eth-nether-genesis.json diff --git a/eth-genesis.json b/eth-genesis.json deleted file mode 100644 index c70530febd..0000000000 --- a/eth-genesis.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "config": { - "chainId": 80000, - "homesteadBlock": 0, - "daoForkBlock": 0, - "daoForkSupport": true, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "berlinBlock": 0, - "londonBlock": 0, - "arrowGlacierBlock": 0, - "grayGlacierBlock": 0, - "mergeNetsplitBlock": 0, - "shanghaiTime": 0, - "cancunTime": 0, - "terminalTotalDifficulty": 0, - "terminalTotalDifficultyPassed": true, - "ethash": { - - } - }, - "alloc": { - "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B": { - "balance": "0x1f972880" - }, - "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500" - }, - "0x4e59b44847b379578588920cA78FbF26c0B4956C": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" - }, - "0x4242424242424242424242424242424242424242": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610abf575080632dfdf0b514610a7b578063560036ec1461094d578063577212fe1461087d5780639eaffa96146107f7578063c53925d914610618578063e12cf4cb1461020b5763fea7ab7714610074575f80fd5b346102075760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576100c3903690600401610b7b565b9060243573ffffffffffffffffffffffffffffffffffffffff81168082036102075773ffffffffffffffffffffffffffffffffffffffff6040518585823760208187810160018152030190205416938433036101df5781156101b7577f7640ec3c8c4695deadda414dd20400acf275297a7c38715f9237657e97ddba5f93606093604051838382376020818581016002815203019020907fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006bffffffffffffffffffffffff421691871b1617905581604051928392833781015f8152039020936040519182526020820152426040820152a2005b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f7c214f04000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f80fd5b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610255903690600401610b7b565b9060243567ffffffffffffffff811161020757610276903690600401610b7b565b60449391933567ffffffffffffffff811161020757610299903690600401610b7b565b5f9291925060643573ffffffffffffffffffffffffffffffffffffffff811680910361020757603085036105f057602083036105c857606082036105a05773ffffffffffffffffffffffffffffffffffffffff6040518688823760208188810160018152030190205416155f1461057357801561054b57604051858782376020818781016001815203019020817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb1740360405186888237808781015f8152039020916040519081525f602082015260408180030190a25b633b9aca00340661052357633b9aca00340467ffffffffffffffff81116104fb575f38818034815af1156104ee5767ffffffffffffffff169064077359400082106104c6575f549367ffffffffffffffff85169467ffffffffffffffff8614610499577f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d469861048e9561047b927fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000067ffffffffffffffff60018b01169116175f5561046d6040519a8b9a60a08c5260a08c0191610ba9565b9189830360208b0152610ba9565b9260408701528583036060870152610ba9565b9060808301520390a1005b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f0e1eddda000000000000000000000000000000000000000000000000000000005f5260045ffd5b63b12d13eb5f526004601cfd5b7f2aa66734000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f40567b38000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f51969a7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b15610395577fc4142b41000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4be6321b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fb39bca16000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f106472000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610667903690600401610b7b565b604051818382376020818381016002815203019020548060601c908133036107cf576bffffffffffffffffffffffff620151809116016bffffffffffffffffffffffff8111610499576bffffffffffffffffffffffff8042169116116107a7577f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb174039173ffffffffffffffffffffffffffffffffffffffff60405182868237602081848101600181520301902054169360405182828237602081848101600181520301902073ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790555f6040518383823760208185810160028152030190205581604051928392833781015f815203902092604051918252602082015260408180030190a2005b7fe8966d7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f819a0d0b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff81116102075773ffffffffffffffffffffffffffffffffffffffff602061085e81933690600401610b7b565b9190826040519384928337810160018152030190205416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576108cc903690600401610b7b565b9073ffffffffffffffffffffffffffffffffffffffff604051838382376020818581016001815203019020541633036101df575f6040518383823760208185810160028152030190205581604051928392833781015f81520390207f1c0a7e1bd09da292425c039309671a03de56b89a0858598aab6df6ce84b006db5f80a2005b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757366023820112156102075780600401359067ffffffffffffffff8211610a4e57604051907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f81601f8601160116820182811067ffffffffffffffff821117610a4e5760405282825260208201913660248584010111610207575f60208560409660248396018737830101528351928391518091835e81016002815203019020548151906bffffffffffffffffffffffff8116825260601c6020820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610207575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757602067ffffffffffffffff5f5416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361020757817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115610b51575b5015158152f35b7f136f920d0000000000000000000000000000000000000000000000000000000091501483610b4a565b9181601f840112156102075782359167ffffffffffffffff8311610207576020838186019501011161020757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f858286010152011601019056fea164736f6c634300081a000a" - }, - "0x6969696969696969696969696969696969696969": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x60806040526004361015610022575b3615610018575f80fd5b610020610a14565b005b5f3560e01c806306fdde03146108fb578063095ea7b31461087257806318160ddd1461082f57806323b872dd146107285780632e1a7d4d1461064f578063313ce567146106165780633644e5151461054c57806370a08231146104fc5780637ecebe00146104ac57806395d89b41146103f5578063a9059cbb14610348578063d0e30db014610317578063d505accf146101205763dd62ed3e0361000e573461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576100f76109aa565b6100ff6109cd565b602052637f5e9f20600c525f5260206034600c2054604051908152f35b5f80fd5b3461011c5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576101576109aa565b61015f6109cd565b6084359160643560443560ff8516850361011c5761017b6109f0565b60208101907f577261707065642042657261000000000000000000000000000000000000000082525190209082421161030a5773ffffffffffffffffffffffffffffffffffffffff80604051951695169565383775081901600e52855f5260c06020600c20958654957f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252602082019586528660408301967fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc688528b6060850198468a528c608087019330855260a08820602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9885252528688525260a082015220604e526042602c205f5260ff1660205260a43560405260c43560605260208060805f60015afa93853d51036102fd577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259460209401905585777f5e9f200000000000000000000000000000000000000000176040526034602c2055a3005b63ddafbaef5f526004601cfd5b631a15a3cc5f526004601cfd5b5f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57610020610a14565b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761037f6109aa565b602435906387a211a2600c52335f526020600c2080548084116103e85783900390555f526020600c20818154019055602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b63f4d678b85f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57604051604081019080821067ffffffffffffffff83111761047f5761047b91604052600581527f5742455241000000000000000000000000000000000000000000000000000000602082015260405191829182610962565b0390f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576104e36109aa565b6338377508600c525f52602080600c2054604051908152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576105336109aa565b6387a211a2600c525f52602080600c2054604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060a06105866109f0565b828101907f57726170706564204265726100000000000000000000000000000000000000008252519020604051907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015220604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060405160128152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576004356387a211a2600c52335f526020600c20908154918282116103e857815f93039055806805345cdf77eb68f44c54036805345cdf77eb68f44c5580825281337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a3808252337f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65602084a281803892335af11561071b57005b63b12d13eb5f526004601cfd5b3461011c5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761075f6109aa565b6107676109cd565b604435908260601b33602052637f5e9f208117600c526034600c20908154916001830161080b575b506387a211a2915017600c526020600c2080548084116103e85783900390555f526020600c2081815401905560205273ffffffffffffffffffffffffffffffffffffffff600c5160601c91167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b82851161082257846387a211a2930390558561078f565b6313be252b5f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5760206805345cdf77eb68f44c54604051908152f35b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576108a96109aa565b60243590602052637f5e9f20600c52335f52806034600c20555f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa3602060405160018152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761047b6109346109f0565b7f57726170706564204265726100000000000000000000000000000000000000006020820152604051918291825b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060409481855280519182918282880152018686015e5f8582860101520116010190565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b604051906040820182811067ffffffffffffffff82111761047f57604052600c8252565b6805345cdf77eb68f44c54348101908110610aa5576805345cdf77eb68f44c556387a211a2600c52335f526020600c2034815401905534602052600c5160601c5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3345f52337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c60205fa2565b63e5cfe9575f526004601cfdfea164736f6c634300081a000a" - } - }, - "coinbase": "0x0000000000000000000000000000000000000000", - "difficulty": "0x01", - "extraData": "", - "gasLimit": "0x1c9c380", - "nonce": "0x1234", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp": "TODO: SET TIMESTAMP" -} diff --git a/eth-nether-genesis.json b/eth-nether-genesis.json deleted file mode 100644 index fd5dbe1bce..0000000000 --- a/eth-nether-genesis.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "name": "cArtio", - "engine": { - "Ethash": { - - } - }, - "params": { - "gasLimitBoundDivisor": "0x400", - "registrar": "0x0000000000000000000000000000000000000000", - "accountStartNonce": "0x0", - "maximumExtraDataSize": "0x20", - "minGasLimit": "0x1c9c380", - "networkID": "0x13880", - "MergeForkIdTransition": "0x0", - "maxCodeSize": "0x6000", - "maxCodeSizeTransition": "0x0", - "eip150Transition": "0x0", - "eip158Transition": "0x0", - "eip160Transition": "0x0", - "eip161abcTransition": "0x0", - "eip161dTransition": "0x0", - "eip155Transition": "0x0", - "eip140Transition": "0x0", - "eip211Transition": "0x0", - "eip214Transition": "0x0", - "eip658Transition": "0x0", - "eip145Transition": "0x0", - "eip1014Transition": "0x0", - "eip1052Transition": "0x0", - "eip1283Transition": "0x0", - "eip1283DisableTransition": "0x0", - "eip152Transition": "0x0", - "eip1108Transition": "0x0", - "eip1344Transition": "0x0", - "eip1884Transition": "0x0", - "eip2028Transition": "0x0", - "eip2200Transition": "0x0", - "eip2565Transition": "0x0", - "eip2929Transition": "0x0", - "eip2930Transition": "0x0", - "eip1559Transition": "0x0", - "eip3198Transition": "0x0", - "eip3529Transition": "0x0", - "eip3541Transition": "0x0", - "eip4895TransitionTimestamp": "0x0", - "eip3855TransitionTimestamp": "0x0", - "eip3651TransitionTimestamp": "0x0", - "eip3860TransitionTimestamp": "0x0", - "eip1153TransitionTimestamp": "0x0", - "eip4844TransitionTimestamp": "0x0", - "eip4788TransitionTimestamp": "0x0", - "eip5656TransitionTimestamp": "0x0", - "eip6780TransitionTimestamp": "0x0", - "terminalTotalDifficulty": "0x0" - }, - "genesis": { - "seal": { - "ethereum": { - "nonce": "0x1234", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" - } - }, - "difficulty": "0x01", - "author": "0x0000000000000000000000000000000000000000", - "timestamp": "TODO: SET TIMESTAMP (HEX)", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "extraData": "", - "gasLimit": "0x1c9c380" - }, - "accounts": { - "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B": { - "balance": "0x1f972880" - }, - "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500" - }, - "0x4e59b44847b379578588920cA78FbF26c0B4956C": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" - }, - "0x4242424242424242424242424242424242424242": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714610abf575080632dfdf0b514610a7b578063560036ec1461094d578063577212fe1461087d5780639eaffa96146107f7578063c53925d914610618578063e12cf4cb1461020b5763fea7ab7714610074575f80fd5b346102075760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576100c3903690600401610b7b565b9060243573ffffffffffffffffffffffffffffffffffffffff81168082036102075773ffffffffffffffffffffffffffffffffffffffff6040518585823760208187810160018152030190205416938433036101df5781156101b7577f7640ec3c8c4695deadda414dd20400acf275297a7c38715f9237657e97ddba5f93606093604051838382376020818581016002815203019020907fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006bffffffffffffffffffffffff421691871b1617905581604051928392833781015f8152039020936040519182526020820152426040820152a2005b7fd92e233d000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f7c214f04000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f80fd5b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610255903690600401610b7b565b9060243567ffffffffffffffff811161020757610276903690600401610b7b565b60449391933567ffffffffffffffff811161020757610299903690600401610b7b565b5f9291925060643573ffffffffffffffffffffffffffffffffffffffff811680910361020757603085036105f057602083036105c857606082036105a05773ffffffffffffffffffffffffffffffffffffffff6040518688823760208188810160018152030190205416155f1461057357801561054b57604051858782376020818781016001815203019020817fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790557f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb1740360405186888237808781015f8152039020916040519081525f602082015260408180030190a25b633b9aca00340661052357633b9aca00340467ffffffffffffffff81116104fb575f38818034815af1156104ee5767ffffffffffffffff169064077359400082106104c6575f549367ffffffffffffffff85169467ffffffffffffffff8614610499577f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d469861048e9561047b927fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000067ffffffffffffffff60018b01169116175f5561046d6040519a8b9a60a08c5260a08c0191610ba9565b9189830360208b0152610ba9565b9260408701528583036060870152610ba9565b9060808301520390a1005b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f0e1eddda000000000000000000000000000000000000000000000000000000005f5260045ffd5b63b12d13eb5f526004601cfd5b7f2aa66734000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f40567b38000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f51969a7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b15610395577fc4142b41000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4be6321b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fb39bca16000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f9f106472000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757610667903690600401610b7b565b604051818382376020818381016002815203019020548060601c908133036107cf576bffffffffffffffffffffffff620151809116016bffffffffffffffffffffffff8111610499576bffffffffffffffffffffffff8042169116116107a7577f0adffd98d3072c48341843974dffd7a910bb849ba6ca04163d43bb26feb174039173ffffffffffffffffffffffffffffffffffffffff60405182868237602081848101600181520301902054169360405182828237602081848101600181520301902073ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790555f6040518383823760208185810160028152030190205581604051928392833781015f815203902092604051918252602082015260408180030190a2005b7fe8966d7a000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f819a0d0b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff81116102075773ffffffffffffffffffffffffffffffffffffffff602061085e81933690600401610b7b565b9190826040519384928337810160018152030190205416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff8111610207576108cc903690600401610b7b565b9073ffffffffffffffffffffffffffffffffffffffff604051838382376020818581016001815203019020541633036101df575f6040518383823760208185810160028152030190205581604051928392833781015f81520390207f1c0a7e1bd09da292425c039309671a03de56b89a0858598aab6df6ce84b006db5f80a2005b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102075760043567ffffffffffffffff811161020757366023820112156102075780600401359067ffffffffffffffff8211610a4e57604051907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f81601f8601160116820182811067ffffffffffffffff821117610a4e5760405282825260208201913660248584010111610207575f60208560409660248396018737830101528351928391518091835e81016002815203019020548151906bffffffffffffffffffffffff8116825260601c6020820152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610207575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757602067ffffffffffffffff5f5416604051908152f35b346102075760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020757600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361020757817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115610b51575b5015158152f35b7f136f920d0000000000000000000000000000000000000000000000000000000091501483610b4a565b9181601f840112156102075782359167ffffffffffffffff8311610207576020838186019501011161020757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f858286010152011601019056fea164736f6c634300081a000a" - }, - "0x6969696969696969696969696969696969696969": { - "balance": "0x0", - "nonce": "0x1", - "code": "0x60806040526004361015610022575b3615610018575f80fd5b610020610a14565b005b5f3560e01c806306fdde03146108fb578063095ea7b31461087257806318160ddd1461082f57806323b872dd146107285780632e1a7d4d1461064f578063313ce567146106165780633644e5151461054c57806370a08231146104fc5780637ecebe00146104ac57806395d89b41146103f5578063a9059cbb14610348578063d0e30db014610317578063d505accf146101205763dd62ed3e0361000e573461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576100f76109aa565b6100ff6109cd565b602052637f5e9f20600c525f5260206034600c2054604051908152f35b5f80fd5b3461011c5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576101576109aa565b61015f6109cd565b6084359160643560443560ff8516850361011c5761017b6109f0565b60208101907f577261707065642042657261000000000000000000000000000000000000000082525190209082421161030a5773ffffffffffffffffffffffffffffffffffffffff80604051951695169565383775081901600e52855f5260c06020600c20958654957f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252602082019586528660408301967fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc688528b6060850198468a528c608087019330855260a08820602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9885252528688525260a082015220604e526042602c205f5260ff1660205260a43560405260c43560605260208060805f60015afa93853d51036102fd577f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259460209401905585777f5e9f200000000000000000000000000000000000000000176040526034602c2055a3005b63ddafbaef5f526004601cfd5b631a15a3cc5f526004601cfd5b5f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57610020610a14565b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761037f6109aa565b602435906387a211a2600c52335f526020600c2080548084116103e85783900390555f526020600c20818154019055602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b63f4d678b85f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57604051604081019080821067ffffffffffffffff83111761047f5761047b91604052600581527f5742455241000000000000000000000000000000000000000000000000000000602082015260405191829182610962565b0390f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576104e36109aa565b6338377508600c525f52602080600c2054604051908152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576105336109aa565b6387a211a2600c525f52602080600c2054604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060a06105866109f0565b828101907f57726170706564204265726100000000000000000000000000000000000000008252519020604051907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8252838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015220604051908152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c57602060405160128152f35b3461011c5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576004356387a211a2600c52335f526020600c20908154918282116103e857815f93039055806805345cdf77eb68f44c54036805345cdf77eb68f44c5580825281337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602083a3808252337f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65602084a281803892335af11561071b57005b63b12d13eb5f526004601cfd5b3461011c5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761075f6109aa565b6107676109cd565b604435908260601b33602052637f5e9f208117600c526034600c20908154916001830161080b575b506387a211a2915017600c526020600c2080548084116103e85783900390555f526020600c2081815401905560205273ffffffffffffffffffffffffffffffffffffffff600c5160601c91167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3602060405160018152f35b82851161082257846387a211a2930390558561078f565b6313be252b5f526004601cfd5b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5760206805345cdf77eb68f44c54604051908152f35b3461011c5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c576108a96109aa565b60243590602052637f5e9f20600c52335f52806034600c20555f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa3602060405160018152f35b3461011c575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261011c5761047b6109346109f0565b7f57726170706564204265726100000000000000000000000000000000000000006020820152604051918291825b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602060409481855280519182918282880152018686015e5f8582860101520116010190565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361011c57565b604051906040820182811067ffffffffffffffff82111761047f57604052600c8252565b6805345cdf77eb68f44c54348101908110610aa5576805345cdf77eb68f44c556387a211a2600c52335f526020600c2034815401905534602052600c5160601c5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3345f52337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c60205fa2565b63e5cfe9575f526004601cfdfea164736f6c634300081a000a" - } - }, - "nodes": [] -} diff --git a/mod/da/pkg/store/pruner_test.go b/mod/da/pkg/store/pruner_test.go index 6b3b12ee56..9b6e8d0a19 100644 --- a/mod/da/pkg/store/pruner_test.go +++ b/mod/da/pkg/store/pruner_test.go @@ -107,14 +107,16 @@ func TestBuildPruneRangeFn(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cs := chain.NewChainSpec( + cs, err := chain.NewChainSpec( chain.SpecData[ bytes.B4, math.U64, common.ExecutionAddress, math.U64, any, ]{ SlotsPerEpoch: tt.slotsPerEpoch, MinEpochsForBlobsSidecarsRequest: tt.minEpochs, + MaxWithdrawalsPerPayload: 1, }, ) + require.NoError(t, err) pruneFn := store.BuildPruneRangeFn[MockBeaconBlock]( cs, ) diff --git a/mod/node-core/pkg/components/dispatcher.go b/mod/node-core/pkg/components/dispatcher.go index 028bbe2e3f..5ba612bca9 100644 --- a/mod/node-core/pkg/components/dispatcher.go +++ b/mod/node-core/pkg/components/dispatcher.go @@ -57,7 +57,9 @@ func ProvideDispatcher[ dp.WithEvent[async.Event[ConsensusSidecars]](async.SidecarsReceived), dp.WithEvent[async.Event[BeaconBlockT]](async.BeaconBlockVerified), dp.WithEvent[async.Event[BlobSidecarsT]](async.SidecarsVerified), - dp.WithEvent[async.Event[ConsensusBlockT]](async.FinalBeaconBlockReceived), + dp.WithEvent[async.Event[ConsensusBlockT]]( + async.FinalBeaconBlockReceived, + ), dp.WithEvent[async.Event[BlobSidecarsT]](async.FinalSidecarsReceived), dp.WithEvent[ValidatorUpdateEvent]( async.FinalValidatorUpdatesProcessed, From 6c91765c74efbbbbbac01ec0a784e0a135541e54 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 15:52:48 -0500 Subject: [PATCH 05/53] gosec --- mod/state-transition/pkg/core/state_processor_staking.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 177d26dd4a..b9970934bc 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -313,7 +313,8 @@ func (sp *StateProcessor[ // Update the next validator index to start the next withdrawal sweep. var nextValIndex math.ValidatorIndex if numWithdrawals > 1 && - uint64(numWithdrawals) == sp.cs.MaxWithdrawalsPerPayload() { + //#nosec:G701 // won't overflow in practice. + numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { // Next sweep starts after the latest withdrawal's validator index. nextValIndex = expectedWithdrawals[numWithdrawals-1].GetIndex() + 1 } else { From 270b6ae502cb62d4772ed9ee8a6e5e094f57205e Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 17:27:11 -0500 Subject: [PATCH 06/53] fix existing unit test --- .../pkg/core/state_processor_staking_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 6c5884f3ac..fa5f9bdf02 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -127,10 +127,17 @@ func TestTransitionUpdateValidators(t *testing.T) { beaconState, &types.BeaconBlockBody{ ExecutionPayload: &types.ExecutionPayload{ - Timestamp: 10, - ExtraData: []byte("testing"), - Transactions: [][]byte{}, - Withdrawals: []*engineprimitives.Withdrawal{}, // no withdrawals + Timestamp: 10, + ExtraData: []byte("testing"), + Transactions: [][]byte{}, + Withdrawals: []*engineprimitives.Withdrawal{ + { // just the EVM inflation withdrawal + Index: 0, + Validator: 0, + Address: cs.EVMInflationAddress(), + Amount: math.U64(cs.EVMInflationPerBlock()), + }, + }, BaseFeePerGas: math.NewU256(0), }, Eth1Data: &types.Eth1Data{}, From ddb711ed60d142e2fe1f8c5b7d207eb25fb42a44 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Fri, 15 Nov 2024 17:41:50 -0500 Subject: [PATCH 07/53] bet --- .../pkg/core/state/statedb.go | 20 +++++++++++++------ .../pkg/core/state_processor_staking_test.go | 8 ++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index e49e79be4a..454246603c 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -203,12 +203,7 @@ func (s *StateDB[ ) // The first withdrawal is fixed to be the EVM inflation withdrawal. - // - // NOTE: The withdrawal index and validator index are both set to 0 as they - // are not used during processing. - withdrawals = append(withdrawals, withdrawal.New( - 0, 0, s.cs.EVMInflationAddress(), math.U64(s.cs.EVMInflationPerBlock()), - )) + withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) slot, err := s.GetSlot() if err != nil { @@ -307,6 +302,19 @@ func (s *StateDB[ return withdrawals, nil } +// EVMInflationWithdrawal returns the withdrawal used for EVM balance inflation. +// +// NOTE: The withdrawal index and validator index are both set to 0 as they are +// not used during processing. +func (s *StateDB[ + _, _, _, _, _, _, _, _, WithdrawalT, _, +]) EVMInflationWithdrawal() WithdrawalT { + var withdrawal WithdrawalT + return withdrawal.New( + 0, 0, s.cs.EVMInflationAddress(), math.U64(s.cs.EVMInflationPerBlock()), + ) +} + // GetMarshallable is the interface for the beacon store. // //nolint:funlen,gocognit // todo fix somehow diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index fa5f9bdf02..e58e68f660 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -131,12 +131,8 @@ func TestTransitionUpdateValidators(t *testing.T) { ExtraData: []byte("testing"), Transactions: [][]byte{}, Withdrawals: []*engineprimitives.Withdrawal{ - { // just the EVM inflation withdrawal - Index: 0, - Validator: 0, - Address: cs.EVMInflationAddress(), - Amount: math.U64(cs.EVMInflationPerBlock()), - }, + // The first withdrawal is always for EVM inflation. + beaconState.EVMInflationWithdrawal(), }, BaseFeePerGas: math.NewU256(0), }, From d898aefe16ed312ef779068e0c52622ad91203da Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 12:30:55 +0100 Subject: [PATCH 08/53] refactor sp tests package --- mod/state-transition/pkg/core/helpers_test.go | 150 +++++++++++------- .../pkg/core/state_processor_genesis_test.go | 69 +------- .../pkg/core/state_processor_staking_test.go | 63 ++------ 3 files changed, 108 insertions(+), 174 deletions(-) diff --git a/mod/state-transition/pkg/core/helpers_test.go b/mod/state-transition/pkg/core/helpers_test.go index 801c696d31..f60e6f615a 100644 --- a/mod/state-transition/pkg/core/helpers_test.go +++ b/mod/state-transition/pkg/core/helpers_test.go @@ -23,6 +23,7 @@ package core_test import ( "context" "fmt" + "os" "testing" corestore "cosmossdk.io/core/store" @@ -30,20 +31,25 @@ import ( "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" + "github.com/berachain/beacon-kit/mod/chain-spec/pkg/chain" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" "github.com/berachain/beacon-kit/mod/log/pkg/noop" "github.com/berachain/beacon-kit/mod/node-core/pkg/components" + "github.com/berachain/beacon-kit/mod/primitives/pkg/bytes" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" - "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto" + cryptomocks "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto/mocks" + "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/mod/primitives/pkg/transition" "github.com/berachain/beacon-kit/mod/state-transition/pkg/core" + "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/mocks" statedb "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/state" "github.com/berachain/beacon-kit/mod/storage/pkg/beacondb" "github.com/berachain/beacon-kit/mod/storage/pkg/db" "github.com/berachain/beacon-kit/mod/storage/pkg/encoding" dbm "github.com/cosmos/cosmos-db" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -84,61 +90,6 @@ type ( ] ) -func createStateProcessor( - cs common.ChainSpec, - execEngine core.ExecutionEngine[ - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - engineprimitives.Withdrawals, - ], - signer crypto.BLSSigner, - fGetAddressFromPubKey func(crypto.BLSPubkey) ([]byte, error), -) *core.StateProcessor[ - *types.BeaconBlock, - *types.BeaconBlockBody, - *types.BeaconBlockHeader, - *TestBeaconStateT, - *transition.Context, - *types.Deposit, - *types.Eth1Data, - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - *types.Fork, - *types.ForkData, - *TestKVStoreT, - *types.Validator, - types.Validators, - *engineprimitives.Withdrawal, - engineprimitives.Withdrawals, - types.WithdrawalCredentials, -] { - return core.NewStateProcessor[ - *types.BeaconBlock, - *types.BeaconBlockBody, - *types.BeaconBlockHeader, - *TestBeaconStateT, - *transition.Context, - *types.Deposit, - *types.Eth1Data, - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - *types.Fork, - *types.ForkData, - *TestKVStoreT, - *types.Validator, - types.Validators, - *engineprimitives.Withdrawal, - engineprimitives.Withdrawals, - types.WithdrawalCredentials, - ]( - noop.NewLogger[any](), - cs, - execEngine, - signer, - fGetAddressFromPubKey, - ) -} - type testKVStoreService struct { ctx sdk.Context } @@ -199,6 +150,93 @@ func initStore() ( ), nil } +// in genesis UTs we don't need to verify proposer address +// (no one proposes genesis), hence the dummy implementation. +func dummyProposerAddressVerifier(bytes.B48) ([]byte, error) { + return nil, nil +} + +func setupState(t *testing.T, chainSpecType string) ( + chain.Spec[bytes.B4, math.U64, common.ExecutionAddress, math.U64, any], + *core.StateProcessor[ + *types.BeaconBlock, + *types.BeaconBlockBody, + *types.BeaconBlockHeader, + *TestBeaconStateT, + *transition.Context, + *types.Deposit, + *types.Eth1Data, + *types.ExecutionPayload, + *types.ExecutionPayloadHeader, + *types.Fork, + *types.ForkData, + *TestKVStoreT, + *types.Validator, + types.Validators, + *engineprimitives.Withdrawal, + engineprimitives.Withdrawals, + types.WithdrawalCredentials, + ], + *TestBeaconStateT, + *transition.Context, +) { + os.Setenv(components.ChainSpecTypeEnvVar, chainSpecType) + cs, err := components.ProvideChainSpec() + require.NoError(t, err) + + execEngine := mocks.NewExecutionEngine[ + *types.ExecutionPayload, + *types.ExecutionPayloadHeader, + engineprimitives.Withdrawals, + ](t) + + mocksSigner := &cryptomocks.BLSSigner{} + mocksSigner.On( + "VerifySignature", + mock.Anything, mock.Anything, mock.Anything, + ).Return(nil) + + dummyProposerAddr := []byte{0xff} + + sp := core.NewStateProcessor[ + *types.BeaconBlock, + *types.BeaconBlockBody, + *types.BeaconBlockHeader, + *TestBeaconStateT, + *transition.Context, + *types.Deposit, + *types.Eth1Data, + *types.ExecutionPayload, + *types.ExecutionPayloadHeader, + *types.Fork, + *types.ForkData, + *TestKVStoreT, + *types.Validator, + types.Validators, + *engineprimitives.Withdrawal, + engineprimitives.Withdrawals, + types.WithdrawalCredentials, + ]( + noop.NewLogger[any](), + cs, + execEngine, + mocksSigner, + dummyProposerAddressVerifier, + ) + + kvStore, err := initStore() + require.NoError(t, err) + beaconState := new(TestBeaconStateT).NewFromDB(kvStore, cs) + + ctx := &transition.Context{ + SkipPayloadVerification: true, + SkipValidateResult: true, + ProposerAddress: dummyProposerAddr, + } + + return cs, sp, beaconState, ctx +} + func buildNextBlock( t *testing.T, beaconState *TestBeaconStateT, diff --git a/mod/state-transition/pkg/core/state_processor_genesis_test.go b/mod/state-transition/pkg/core/state_processor_genesis_test.go index 79ee13281f..0f7ab2fe0e 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis_test.go +++ b/mod/state-transition/pkg/core/state_processor_genesis_test.go @@ -24,42 +24,17 @@ import ( "testing" "github.com/berachain/beacon-kit/mod/chain-spec/pkg/chain" - "github.com/berachain/beacon-kit/mod/config/pkg/spec" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" - engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" - "github.com/berachain/beacon-kit/mod/primitives/pkg/bytes" + "github.com/berachain/beacon-kit/mod/node-core/pkg/components" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" "github.com/berachain/beacon-kit/mod/primitives/pkg/constants" - cryptomocks "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto/mocks" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/mod/primitives/pkg/version" - "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/mocks" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestInitialize(t *testing.T) { - // Create state processor to test - cs, err := spec.BetnetChainSpec() - require.NoError(t, err) - execEngine := mocks.NewExecutionEngine[ - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - engineprimitives.Withdrawals, - ](t) - mocksSigner := &cryptomocks.BLSSigner{} - - sp := createStateProcessor( - cs, - execEngine, - mocksSigner, - dummyProposerAddressVerifier, - ) - - // create test inputs - kvStore, err := initStore() - require.NoError(t, err) - beaconState := new(TestBeaconStateT).NewFromDB(kvStore, cs) + cs, sp, beaconState, _ := setupState(t, components.BetnetChainSpecType) var ( deposits = []*types.Deposit{ @@ -97,12 +72,6 @@ func TestInitialize(t *testing.T) { } ) - // define mocks expectations - mocksSigner.On( - "VerifySignature", - mock.Anything, mock.Anything, mock.Anything, - ).Return(nil) - // run test vals, err := sp.InitializePreminedBeaconStateFromEth1( beaconState, @@ -161,27 +130,7 @@ func checkValidatorNonBartio( } func TestInitializeBartio(t *testing.T) { - // Create state processor to test - cs, err := spec.TestnetChainSpec() - require.NoError(t, err) - execEngine := mocks.NewExecutionEngine[ - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - engineprimitives.Withdrawals, - ](t) - mocksSigner := &cryptomocks.BLSSigner{} - - sp := createStateProcessor( - cs, - execEngine, - mocksSigner, - dummyProposerAddressVerifier, - ) - - // create test inputs - kvStore, err := initStore() - require.NoError(t, err) - beaconState := new(TestBeaconStateT).NewFromDB(kvStore, cs) + cs, sp, beaconState, _ := setupState(t, "testnet") var ( deposits = []*types.Deposit{ @@ -219,12 +168,6 @@ func TestInitializeBartio(t *testing.T) { } ) - // define mocks expectations - mocksSigner.On( - "VerifySignature", - mock.Anything, mock.Anything, mock.Anything, - ).Return(nil) - // run test vals, err := sp.InitializePreminedBeaconStateFromEth1( beaconState, @@ -322,9 +265,3 @@ func commonChecksValidators( require.Equal(t, math.Gwei(0), val.EffectiveBalance) } } - -// in genesis UTs we don't need to verify proposer address -// (no one proposes genesis), hence the dummy implementation. -func dummyProposerAddressVerifier(bytes.B48) ([]byte, error) { - return nil, nil -} diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index e58e68f660..785297af08 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -23,44 +23,17 @@ package core_test import ( "testing" - "github.com/berachain/beacon-kit/mod/config/pkg/spec" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" - "github.com/berachain/beacon-kit/mod/primitives/pkg/bytes" + "github.com/berachain/beacon-kit/mod/node-core/pkg/components" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" - cryptomocks "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto/mocks" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" - "github.com/berachain/beacon-kit/mod/primitives/pkg/transition" "github.com/berachain/beacon-kit/mod/primitives/pkg/version" - "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/mocks" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestTransitionUpdateValidators(t *testing.T) { - // Create state processor to test - cs, err := spec.BetnetChainSpec() - require.NoError(t, err) - execEngine := mocks.NewExecutionEngine[ - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - engineprimitives.Withdrawals, - ](t) - mocksSigner := &cryptomocks.BLSSigner{} - dummyProposerAddr := []byte{0xff} - - sp := createStateProcessor( - cs, - execEngine, - mocksSigner, - func(bytes.B48) ([]byte, error) { - return dummyProposerAddr, nil - }, - ) - - kvStore, err := initStore() - require.NoError(t, err) - beaconState := new(TestBeaconStateT).NewFromDB(kvStore, cs) + cs, sp, beaconState, ctx := setupState(t, components.BetnetChainSpecType) var ( maxBalance = math.Gwei(cs.MaxEffectiveBalance()) @@ -91,13 +64,7 @@ func TestTransitionUpdateValidators(t *testing.T) { genPayloadHeader = new(types.ExecutionPayloadHeader).Empty() genVersion = version.FromUint32[common.Version](version.Deneb) ) - - mocksSigner.On( - "VerifySignature", - mock.Anything, mock.Anything, mock.Anything, - ).Return(nil) - - _, err = sp.InitializePreminedBeaconStateFromEth1( + _, err := sp.InitializePreminedBeaconStateFromEth1( beaconState, genDeposits, genPayloadHeader, @@ -106,22 +73,14 @@ func TestTransitionUpdateValidators(t *testing.T) { require.NoError(t, err) // create test inputs - var ( - ctx = &transition.Context{ - SkipPayloadVerification: true, - SkipValidateResult: true, - ProposerAddress: dummyProposerAddr, - } - blkDeposits = []*types.Deposit{ - { - Pubkey: genDeposits[0].Pubkey, - Credentials: emptyCredentials, - Amount: minBalance, // avoid breaching maxBalance - Index: genDeposits[0].Index, - }, - } - ) - + blkDeposits := []*types.Deposit{ + { + Pubkey: genDeposits[0].Pubkey, + Credentials: emptyCredentials, + Amount: minBalance, // avoid breaching maxBalance + Index: genDeposits[0].Index, + }, + } blk := buildNextBlock( t, beaconState, From afea1e71d9dbccf2223d9243dbbf8e82f9ff8f74 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 12:33:54 +0100 Subject: [PATCH 09/53] fix & rename file --- .../pkg/core/{helpers_test.go => core_test.go} | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) rename mod/state-transition/pkg/core/{helpers_test.go => core_test.go} (96%) diff --git a/mod/state-transition/pkg/core/helpers_test.go b/mod/state-transition/pkg/core/core_test.go similarity index 96% rename from mod/state-transition/pkg/core/helpers_test.go rename to mod/state-transition/pkg/core/core_test.go index f60e6f615a..345b366c49 100644 --- a/mod/state-transition/pkg/core/helpers_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -150,12 +150,6 @@ func initStore() ( ), nil } -// in genesis UTs we don't need to verify proposer address -// (no one proposes genesis), hence the dummy implementation. -func dummyProposerAddressVerifier(bytes.B48) ([]byte, error) { - return nil, nil -} - func setupState(t *testing.T, chainSpecType string) ( chain.Spec[bytes.B4, math.U64, common.ExecutionAddress, math.U64, any], *core.StateProcessor[ @@ -221,7 +215,9 @@ func setupState(t *testing.T, chainSpecType string) ( cs, execEngine, mocksSigner, - dummyProposerAddressVerifier, + func(bytes.B48) ([]byte, error) { + return dummyProposerAddr, nil + }, ) kvStore, err := initStore() From 3c11427126fcd8a5a24442f6d37f6293b6a90ad7 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 15:47:32 +0100 Subject: [PATCH 10/53] transition withdrawals test --- mod/chain-spec/pkg/chain/chain_spec.go | 2 +- mod/chain-spec/pkg/chain/errors.go | 4 +- .../pkg/core/state/statedb.go | 5 +- .../pkg/core/state_processor_genesis_test.go | 50 ++++---- .../pkg/core/state_processor_staking.go | 4 +- .../pkg/core/state_processor_staking_test.go | 116 +++++++++++++++--- 6 files changed, 129 insertions(+), 52 deletions(-) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index 37139e28ed..03acfae76f 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -233,7 +233,7 @@ func NewChainSpec[ func (c *chainSpec[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, ]) validate() error { - if c.MaxWithdrawalsPerPayload() == 0 { + if c.MaxWithdrawalsPerPayload() <= 1 { return ErrZeroMaxWithdrawalsPerPayload } diff --git a/mod/chain-spec/pkg/chain/errors.go b/mod/chain-spec/pkg/chain/errors.go index e99c2cf162..644e055920 100644 --- a/mod/chain-spec/pkg/chain/errors.go +++ b/mod/chain-spec/pkg/chain/errors.go @@ -25,7 +25,7 @@ import "github.com/berachain/beacon-kit/mod/errors" var ( // ErrZeroMaxWithdrawalsPerPayload is returned when the max withdrawals // per payload is zero. Must allow at least one for the EVM inflation - // withdrawal. + // withdrawal, and at least one more for a validator withdrawal per block. ErrZeroMaxWithdrawalsPerPayload = errors.New( - "max withdrawals per payload must be greater than 0") + "max withdrawals per payload must be greater than 1") ) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 454246603c..81da4536d6 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -294,9 +294,8 @@ func (s *StateDB[ } // Increment the validator index to process the next validator. - validatorIndex = (validatorIndex + 1) % math.ValidatorIndex( - totalValidators, - ) + validatorIndex++ + validatorIndex %= math.ValidatorIndex(totalValidators) } return withdrawals, nil diff --git a/mod/state-transition/pkg/core/state_processor_genesis_test.go b/mod/state-transition/pkg/core/state_processor_genesis_test.go index 0f7ab2fe0e..7194852f86 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis_test.go +++ b/mod/state-transition/pkg/core/state_processor_genesis_test.go @@ -34,34 +34,34 @@ import ( ) func TestInitialize(t *testing.T) { - cs, sp, beaconState, _ := setupState(t, components.BetnetChainSpecType) + cs, sp, st, _ := setupState(t, components.BetnetChainSpecType) var ( deposits = []*types.Deposit{ { Pubkey: [48]byte{0x01}, Amount: math.Gwei(cs.MaxEffectiveBalance()), - Index: uint64(0), + Index: 0, }, { Pubkey: [48]byte{0x02}, Amount: math.Gwei(cs.MaxEffectiveBalance() / 2), - Index: uint64(1), + Index: 1, }, { Pubkey: [48]byte{0x03}, Amount: math.Gwei(cs.EffectiveBalanceIncrement()), - Index: uint64(2), + Index: 2, }, { Pubkey: [48]byte{0x04}, Amount: math.Gwei(2 * cs.MaxEffectiveBalance()), - Index: uint64(3), + Index: 3, }, { Pubkey: [48]byte{0x05}, Amount: math.Gwei(cs.EffectiveBalanceIncrement() * 2 / 3), - Index: uint64(4), + Index: 4, }, } executionPayloadHeader = new(types.ExecutionPayloadHeader).Empty() @@ -74,10 +74,7 @@ func TestInitialize(t *testing.T) { // run test vals, err := sp.InitializePreminedBeaconStateFromEth1( - beaconState, - deposits, - executionPayloadHeader, - fork.CurrentVersion, + st, deposits, executionPayloadHeader, fork.CurrentVersion, ) // check outputs @@ -85,20 +82,20 @@ func TestInitialize(t *testing.T) { require.Len(t, vals, len(deposits)) // check beacon state changes - resSlot, err := beaconState.GetSlot() + resSlot, err := st.GetSlot() require.NoError(t, err) require.Equal(t, math.Slot(0), resSlot) - resFork, err := beaconState.GetFork() + resFork, err := st.GetFork() require.NoError(t, err) require.Equal(t, fork, resFork) for _, dep := range deposits { - checkValidatorNonBartio(t, cs, beaconState, dep) + checkValidatorNonBartio(t, cs, st, dep) } // check that validator index is duly set - latestValIdx, err := beaconState.GetEth1DepositIndex() + latestValIdx, err := st.GetEth1DepositIndex() require.NoError(t, err) require.Equal(t, uint64(len(deposits)-1), latestValIdx) } @@ -130,34 +127,34 @@ func checkValidatorNonBartio( } func TestInitializeBartio(t *testing.T) { - cs, sp, beaconState, _ := setupState(t, "testnet") + cs, sp, st, _ := setupState(t, "testnet") var ( deposits = []*types.Deposit{ { Pubkey: [48]byte{0x01}, Amount: math.Gwei(cs.MaxEffectiveBalance()), - Index: uint64(0), + Index: 0, }, { Pubkey: [48]byte{0x02}, Amount: math.Gwei(cs.MaxEffectiveBalance() / 2), - Index: uint64(1), + Index: 1, }, { Pubkey: [48]byte{0x03}, Amount: math.Gwei(cs.EffectiveBalanceIncrement()), - Index: uint64(2), + Index: 2, }, { Pubkey: [48]byte{0x04}, Amount: math.Gwei(2 * cs.MaxEffectiveBalance()), - Index: uint64(3), + Index: 3, }, { Pubkey: [48]byte{0x05}, Amount: math.Gwei(cs.EffectiveBalanceIncrement() * 2 / 3), - Index: uint64(4), + Index: 4, }, } executionPayloadHeader = new(types.ExecutionPayloadHeader).Empty() @@ -170,10 +167,7 @@ func TestInitializeBartio(t *testing.T) { // run test vals, err := sp.InitializePreminedBeaconStateFromEth1( - beaconState, - deposits, - executionPayloadHeader, - fork.CurrentVersion, + st, deposits, executionPayloadHeader, fork.CurrentVersion, ) // check outputs @@ -181,20 +175,20 @@ func TestInitializeBartio(t *testing.T) { require.Len(t, vals, len(deposits)) // check beacon state changes - resSlot, err := beaconState.GetSlot() + resSlot, err := st.GetSlot() require.NoError(t, err) require.Equal(t, math.Slot(0), resSlot) - resFork, err := beaconState.GetFork() + resFork, err := st.GetFork() require.NoError(t, err) require.Equal(t, fork, resFork) for _, dep := range deposits { - checkValidatorBartio(t, cs, beaconState, dep) + checkValidatorBartio(t, cs, st, dep) } // check that validator index is duly set - latestValIdx, err := beaconState.GetEth1DepositIndex() + latestValIdx, err := st.GetEth1DepositIndex() require.NoError(t, err) require.Equal(t, uint64(len(deposits)-1), latestValIdx) } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index b9970934bc..2c679dc0a8 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -316,7 +316,8 @@ func (sp *StateProcessor[ //#nosec:G701 // won't overflow in practice. numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { // Next sweep starts after the latest withdrawal's validator index. - nextValIndex = expectedWithdrawals[numWithdrawals-1].GetIndex() + 1 + nextValIndex = + expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1 } else { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. @@ -327,6 +328,5 @@ func (sp *StateProcessor[ nextValIndex += math.U64(sp.cs.MaxValidatorsPerWithdrawalsSweep()) } nextValIndex %= math.U64(totalValidators) - return st.SetNextWithdrawalValidatorIndex(nextValIndex) } diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 785297af08..004858dfae 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -33,14 +33,13 @@ import ( ) func TestTransitionUpdateValidators(t *testing.T) { - cs, sp, beaconState, ctx := setupState(t, components.BetnetChainSpecType) + cs, sp, st, ctx := setupState(t, components.BetnetChainSpecType) var ( maxBalance = math.Gwei(cs.MaxEffectiveBalance()) minBalance = math.Gwei(cs.EffectiveBalanceIncrement()) - emptyAddress = common.ExecutionAddress{} emptyCredentials = types.NewCredentialsFromExecutionAddress( - emptyAddress, + common.ExecutionAddress{}, ) ) @@ -52,23 +51,20 @@ func TestTransitionUpdateValidators(t *testing.T) { Pubkey: [48]byte{0x01}, Credentials: emptyCredentials, Amount: maxBalance - 3*minBalance, - Index: uint64(0), + Index: 0, }, { Pubkey: [48]byte{0x02}, Credentials: emptyCredentials, Amount: maxBalance - 6*minBalance, - Index: uint64(1), + Index: 1, }, } genPayloadHeader = new(types.ExecutionPayloadHeader).Empty() genVersion = version.FromUint32[common.Version](version.Deneb) ) _, err := sp.InitializePreminedBeaconStateFromEth1( - beaconState, - genDeposits, - genPayloadHeader, - genVersion, + st, genDeposits, genPayloadHeader, genVersion, ) require.NoError(t, err) @@ -83,7 +79,7 @@ func TestTransitionUpdateValidators(t *testing.T) { } blk := buildNextBlock( t, - beaconState, + st, &types.BeaconBlockBody{ ExecutionPayload: &types.ExecutionPayload{ Timestamp: 10, @@ -91,7 +87,7 @@ func TestTransitionUpdateValidators(t *testing.T) { Transactions: [][]byte{}, Withdrawals: []*engineprimitives.Withdrawal{ // The first withdrawal is always for EVM inflation. - beaconState.EVMInflationWithdrawal(), + st.EVMInflationWithdrawal(), }, BaseFeePerGas: math.NewU256(0), }, @@ -101,7 +97,7 @@ func TestTransitionUpdateValidators(t *testing.T) { ) // run the test - vals, err := sp.Transition(ctx, beaconState, blk) + vals, err := sp.Transition(ctx, st, blk) // check outputs require.NoError(t, err) @@ -109,22 +105,110 @@ func TestTransitionUpdateValidators(t *testing.T) { // check validator is duly updated expectedValBalance := genDeposits[0].Amount + blkDeposits[0].Amount - idx, err := beaconState.ValidatorIndexByPubkey(genDeposits[0].Pubkey) + idx, err := st.ValidatorIndexByPubkey(genDeposits[0].Pubkey) require.NoError(t, err) require.Equal(t, math.U64(genDeposits[0].Index), idx) - val, err := beaconState.ValidatorByIndex(idx) + val, err := st.ValidatorByIndex(idx) require.NoError(t, err) require.Equal(t, genDeposits[0].Pubkey, val.Pubkey) require.Equal(t, expectedValBalance, val.EffectiveBalance) // check validator balance is updated - valBal, err := beaconState.GetBalance(idx) + valBal, err := st.GetBalance(idx) require.NoError(t, err) require.Equal(t, expectedValBalance, valBal) // check that validator index is duly set (1-indexed here, to be fixed) - latestValIdx, err := beaconState.GetEth1DepositIndex() + latestValIdx, err := st.GetEth1DepositIndex() require.NoError(t, err) require.Equal(t, uint64(len(genDeposits)), latestValIdx) } + +func TestTransitionWithdrawals(t *testing.T) { + cs, sp, st, ctx := setupState(t, components.BetnetChainSpecType) + + var ( + maxBalance = math.Gwei(cs.MaxEffectiveBalance()) + minBalance = math.Gwei(cs.EffectiveBalanceIncrement()) + credentials0 = types.NewCredentialsFromExecutionAddress( + common.ExecutionAddress{}, + ) + address1 = common.ExecutionAddress{0x01} + credentials1 = types.NewCredentialsFromExecutionAddress(address1) + ) + + // Setup initial state so that validator 1 is partially withdrawable. + var ( + genDeposits = []*types.Deposit{ + { + Pubkey: [48]byte{0x00}, + Credentials: credentials0, + Amount: maxBalance - 3*minBalance, + Index: 0, + }, + { + Pubkey: [48]byte{0x01}, + Credentials: credentials1, + Amount: maxBalance + minBalance, + Index: 1, + }, + } + genPayloadHeader = new(types.ExecutionPayloadHeader).Empty() + genVersion = version.FromUint32[common.Version](version.Deneb) + ) + _, err := sp.InitializePreminedBeaconStateFromEth1( + st, genDeposits, genPayloadHeader, genVersion, + ) + require.NoError(t, err) + + // Assert validator 1 balance before withdrawal. + val1Bal, err := st.GetBalance(math.U64(1)) + require.NoError(t, err) + require.Equal(t, maxBalance+minBalance, val1Bal) + + // Create test inputs. + blk := buildNextBlock( + t, + st, + &types.BeaconBlockBody{ + ExecutionPayload: &types.ExecutionPayload{ + Timestamp: 10, + ExtraData: []byte("testing"), + Transactions: [][]byte{}, + Withdrawals: []*engineprimitives.Withdrawal{ + // The first withdrawal is always for EVM inflation. + st.EVMInflationWithdrawal(), + // Partially withdraw validator 1 by minBalance. + { + Index: 0, + Validator: 1, + Amount: minBalance, + Address: address1, + }, + }, + BaseFeePerGas: math.NewU256(0), + }, + Eth1Data: &types.Eth1Data{}, + Deposits: []*types.Deposit{}, + }, + ) + + // Run the test. + vals, err := sp.Transition(ctx, st, blk) + + // Check outputs and ensure withdrawals in payload is consistent with + // statedb expected withdrawals. + require.NoError(t, err) + require.Zero(t, vals) + + // Assert validator 1 balance after withdrawal. + val1BalAfter, err := st.GetBalance(math.U64(1)) + require.NoError(t, err) + require.Equal(t, maxBalance, val1BalAfter) +} + +// TODO: use chain spec with max withdrawals set to 2. +func TestTransitionMaxWithdrawals(t *testing.T) { + +} From ff487e9dcb0a34a2ccc5d540290d7bbe86b9a208 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 17:21:24 +0100 Subject: [PATCH 11/53] bet --- mod/chain-spec/pkg/chain/helpers_test.go | 2 +- mod/da/pkg/store/pruner_test.go | 4 +- mod/state-transition/pkg/core/core_test.go | 26 +++-- mod/state-transition/pkg/core/errors.go | 5 + .../pkg/core/state_processor_genesis_test.go | 26 +++-- .../pkg/core/state_processor_staking.go | 2 +- .../pkg/core/state_processor_staking_test.go | 108 +++++++++++++++++- 7 files changed, 145 insertions(+), 28 deletions(-) diff --git a/mod/chain-spec/pkg/chain/helpers_test.go b/mod/chain-spec/pkg/chain/helpers_test.go index 767f6ae8dd..1de79f616c 100644 --- a/mod/chain-spec/pkg/chain/helpers_test.go +++ b/mod/chain-spec/pkg/chain/helpers_test.go @@ -48,7 +48,7 @@ var spec, _ = chain.NewChainSpec( ElectraForkEpoch: 10, SlotsPerEpoch: 32, MinEpochsForBlobsSidecarsRequest: 5, - MaxWithdrawalsPerPayload: 1, + MaxWithdrawalsPerPayload: 2, }, ) diff --git a/mod/da/pkg/store/pruner_test.go b/mod/da/pkg/store/pruner_test.go index 9b6e8d0a19..506b041780 100644 --- a/mod/da/pkg/store/pruner_test.go +++ b/mod/da/pkg/store/pruner_test.go @@ -113,14 +113,14 @@ func TestBuildPruneRangeFn(t *testing.T) { ]{ SlotsPerEpoch: tt.slotsPerEpoch, MinEpochsForBlobsSidecarsRequest: tt.minEpochs, - MaxWithdrawalsPerPayload: 1, + MaxWithdrawalsPerPayload: 2, }, ) require.NoError(t, err) pruneFn := store.BuildPruneRangeFn[MockBeaconBlock]( cs, ) - event := async.NewEvent[MockBeaconBlock]( + event := async.NewEvent( context.Background(), async.EventID("mock"), MockBeaconBlock{ diff --git a/mod/state-transition/pkg/core/core_test.go b/mod/state-transition/pkg/core/core_test.go index 345b366c49..a65df0a757 100644 --- a/mod/state-transition/pkg/core/core_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -23,7 +23,6 @@ package core_test import ( "context" "fmt" - "os" "testing" corestore "cosmossdk.io/core/store" @@ -150,8 +149,23 @@ func initStore() ( ), nil } -func setupState(t *testing.T, chainSpecType string) ( - chain.Spec[bytes.B4, math.U64, common.ExecutionAddress, math.U64, any], +func setupChain(t *testing.T, chainSpecType string) chain.Spec[ + bytes.B4, math.U64, common.ExecutionAddress, math.U64, any, +] { + t.Helper() + + t.Setenv(components.ChainSpecTypeEnvVar, chainSpecType) + cs, err := components.ProvideChainSpec() + require.NoError(t, err) + + return cs +} + +func setupState( + t *testing.T, cs chain.Spec[ + bytes.B4, math.U64, common.ExecutionAddress, math.U64, any, + ], +) ( *core.StateProcessor[ *types.BeaconBlock, *types.BeaconBlockBody, @@ -174,9 +188,7 @@ func setupState(t *testing.T, chainSpecType string) ( *TestBeaconStateT, *transition.Context, ) { - os.Setenv(components.ChainSpecTypeEnvVar, chainSpecType) - cs, err := components.ProvideChainSpec() - require.NoError(t, err) + t.Helper() execEngine := mocks.NewExecutionEngine[ *types.ExecutionPayload, @@ -230,7 +242,7 @@ func setupState(t *testing.T, chainSpecType string) ( ProposerAddress: dummyProposerAddr, } - return cs, sp, beaconState, ctx + return sp, beaconState, ctx } func buildNextBlock( diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index f973a8865b..fb66ea1414 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -90,4 +90,9 @@ var ( // in the block is not the EVM inflation withdrawal. ErrFirstWithdrawalNotEVMInflation = errors.New( "first withdrawal is not the EVM inflation withdrawal") + + // ErrWithdrawalMismatch is returned when the withdrawals in a payload do + // not match the local state's expected value. + ErrWithdrawalMismatch = errors.New( + "withdrawal mismatch between local state and payload") ) diff --git a/mod/state-transition/pkg/core/state_processor_genesis_test.go b/mod/state-transition/pkg/core/state_processor_genesis_test.go index 7194852f86..389b9c1078 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis_test.go +++ b/mod/state-transition/pkg/core/state_processor_genesis_test.go @@ -34,32 +34,33 @@ import ( ) func TestInitialize(t *testing.T) { - cs, sp, st, _ := setupState(t, components.BetnetChainSpecType) + cs := setupChain(t, components.BetnetChainSpecType) + sp, st, _ := setupState(t, cs) var ( deposits = []*types.Deposit{ { - Pubkey: [48]byte{0x01}, + Pubkey: [48]byte{0x00}, Amount: math.Gwei(cs.MaxEffectiveBalance()), Index: 0, }, { - Pubkey: [48]byte{0x02}, + Pubkey: [48]byte{0x01}, Amount: math.Gwei(cs.MaxEffectiveBalance() / 2), Index: 1, }, { - Pubkey: [48]byte{0x03}, + Pubkey: [48]byte{0x02}, Amount: math.Gwei(cs.EffectiveBalanceIncrement()), Index: 2, }, { - Pubkey: [48]byte{0x04}, + Pubkey: [48]byte{0x03}, Amount: math.Gwei(2 * cs.MaxEffectiveBalance()), Index: 3, }, { - Pubkey: [48]byte{0x05}, + Pubkey: [48]byte{0x04}, Amount: math.Gwei(cs.EffectiveBalanceIncrement() * 2 / 3), Index: 4, }, @@ -127,32 +128,33 @@ func checkValidatorNonBartio( } func TestInitializeBartio(t *testing.T) { - cs, sp, st, _ := setupState(t, "testnet") + cs := setupChain(t, "testnet") + sp, st, _ := setupState(t, cs) var ( deposits = []*types.Deposit{ { - Pubkey: [48]byte{0x01}, + Pubkey: [48]byte{0x00}, Amount: math.Gwei(cs.MaxEffectiveBalance()), Index: 0, }, { - Pubkey: [48]byte{0x02}, + Pubkey: [48]byte{0x01}, Amount: math.Gwei(cs.MaxEffectiveBalance() / 2), Index: 1, }, { - Pubkey: [48]byte{0x03}, + Pubkey: [48]byte{0x02}, Amount: math.Gwei(cs.EffectiveBalanceIncrement()), Index: 2, }, { - Pubkey: [48]byte{0x04}, + Pubkey: [48]byte{0x03}, Amount: math.Gwei(2 * cs.MaxEffectiveBalance()), Index: 3, }, { - Pubkey: [48]byte{0x05}, + Pubkey: [48]byte{0x04}, Amount: math.Gwei(cs.EffectiveBalanceIncrement() * 2 / 3), Index: 4, }, diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 2c679dc0a8..6a0163fa1b 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -274,7 +274,7 @@ func (sp *StateProcessor[ // Ensure the withdrawals match the local state. if !wd.Equals(payloadWithdrawals[i]) { return errors.Wrapf( - ErrNumWithdrawalsMismatch, + ErrWithdrawalMismatch, "withdrawals do not match expected %s, got %s", spew.Sdump(wd), spew.Sdump(payloadWithdrawals[i]), ) diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 004858dfae..bf7e95085d 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -23,6 +23,8 @@ package core_test import ( "testing" + "github.com/berachain/beacon-kit/mod/chain-spec/pkg/chain" + "github.com/berachain/beacon-kit/mod/config/pkg/spec" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" "github.com/berachain/beacon-kit/mod/node-core/pkg/components" @@ -33,7 +35,8 @@ import ( ) func TestTransitionUpdateValidators(t *testing.T) { - cs, sp, st, ctx := setupState(t, components.BetnetChainSpecType) + cs := setupChain(t, components.BetnetChainSpecType) + sp, st, ctx := setupState(t, cs) var ( maxBalance = math.Gwei(cs.MaxEffectiveBalance()) @@ -48,13 +51,13 @@ func TestTransitionUpdateValidators(t *testing.T) { var ( genDeposits = []*types.Deposit{ { - Pubkey: [48]byte{0x01}, + Pubkey: [48]byte{0x00}, Credentials: emptyCredentials, Amount: maxBalance - 3*minBalance, Index: 0, }, { - Pubkey: [48]byte{0x02}, + Pubkey: [48]byte{0x01}, Credentials: emptyCredentials, Amount: maxBalance - 6*minBalance, Index: 1, @@ -126,7 +129,8 @@ func TestTransitionUpdateValidators(t *testing.T) { } func TestTransitionWithdrawals(t *testing.T) { - cs, sp, st, ctx := setupState(t, components.BetnetChainSpecType) + cs := setupChain(t, components.BetnetChainSpecType) + sp, st, ctx := setupState(t, cs) var ( maxBalance = math.Gwei(cs.MaxEffectiveBalance()) @@ -208,7 +212,101 @@ func TestTransitionWithdrawals(t *testing.T) { require.Equal(t, maxBalance, val1BalAfter) } -// TODO: use chain spec with max withdrawals set to 2. func TestTransitionMaxWithdrawals(t *testing.T) { + // Use custom chain spec with max withdrawals set to 2. + csData := spec.BaseSpec() + csData.DepositEth1ChainID = spec.BetnetEth1ChainID + csData.MaxWithdrawalsPerPayload = 2 + cs, err := chain.NewChainSpec(csData) + require.NoError(t, err) + + sp, st, ctx := setupState(t, cs) + + var ( + maxBalance = math.Gwei(cs.MaxEffectiveBalance()) + minBalance = math.Gwei(cs.EffectiveBalanceIncrement()) + address0 = common.ExecutionAddress{} + credentials0 = types.NewCredentialsFromExecutionAddress(address0) + credentials1 = types.NewCredentialsFromExecutionAddress( + common.ExecutionAddress{0x01}, + ) + ) + + // Setup initial state so that both validators are partially withdrawable. + var ( + genDeposits = []*types.Deposit{ + { + Pubkey: [48]byte{0x00}, + Credentials: credentials0, + Amount: maxBalance + minBalance, + Index: 0, + }, + { + Pubkey: [48]byte{0x01}, + Credentials: credentials1, + Amount: maxBalance + minBalance, + Index: 1, + }, + } + genPayloadHeader = new(types.ExecutionPayloadHeader).Empty() + genVersion = version.FromUint32[common.Version](version.Deneb) + ) + _, err = sp.InitializePreminedBeaconStateFromEth1( + st, genDeposits, genPayloadHeader, genVersion, + ) + require.NoError(t, err) + // Assert validator balances before withdrawal. + val0Bal, err := st.GetBalance(math.U64(0)) + require.NoError(t, err) + require.Equal(t, maxBalance+minBalance, val0Bal) + + val1Bal, err := st.GetBalance(math.U64(1)) + require.NoError(t, err) + require.Equal(t, maxBalance+minBalance, val1Bal) + + // Create test inputs. + blk := buildNextBlock( + t, + st, + &types.BeaconBlockBody{ + ExecutionPayload: &types.ExecutionPayload{ + Timestamp: 10, + ExtraData: []byte("testing"), + Transactions: [][]byte{}, + Withdrawals: []*engineprimitives.Withdrawal{ + // The first withdrawal is always for EVM inflation. + st.EVMInflationWithdrawal(), + // Partially withdraw validator 0 by minBalance. + { + Index: 0, + Validator: 0, + Amount: minBalance, + Address: address0, + }, + }, + BaseFeePerGas: math.NewU256(0), + }, + Eth1Data: &types.Eth1Data{}, + Deposits: []*types.Deposit{}, + }, + ) + + // Run the test. + vals, err := sp.Transition(ctx, st, blk) + + // Check outputs and ensure withdrawals in payload is consistent with + // statedb expected withdrawals. + require.NoError(t, err) + require.Zero(t, vals) + + // Assert validator balances after withdrawal, ensuring only validator 0 is + // withdrawn from. + val0BalAfter, err := st.GetBalance(math.U64(0)) + require.NoError(t, err) + require.Equal(t, maxBalance, val0BalAfter) + + val1BalAfter, err := st.GetBalance(math.U64(1)) + require.NoError(t, err) + require.Equal(t, maxBalance+minBalance, val1BalAfter) } From 220f49928828bfdd1e6b0979282f47b3b44982be Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 17:28:15 +0100 Subject: [PATCH 12/53] edge case --- .../pkg/core/state_processor_staking_test.go | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index bf7e95085d..245278840c 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -227,9 +227,8 @@ func TestTransitionMaxWithdrawals(t *testing.T) { minBalance = math.Gwei(cs.EffectiveBalanceIncrement()) address0 = common.ExecutionAddress{} credentials0 = types.NewCredentialsFromExecutionAddress(address0) - credentials1 = types.NewCredentialsFromExecutionAddress( - common.ExecutionAddress{0x01}, - ) + address1 = common.ExecutionAddress{0x01} + credentials1 = types.NewCredentialsFromExecutionAddress(address1) ) // Setup initial state so that both validators are partially withdrawable. @@ -309,4 +308,43 @@ func TestTransitionMaxWithdrawals(t *testing.T) { val1BalAfter, err := st.GetBalance(math.U64(1)) require.NoError(t, err) require.Equal(t, maxBalance+minBalance, val1BalAfter) + + // Process the next block, ensuring that validator 1 is also withdrawn from. + blk = buildNextBlock( + t, + st, + &types.BeaconBlockBody{ + ExecutionPayload: &types.ExecutionPayload{ + Timestamp: 10, + ExtraData: []byte("testing"), + Transactions: [][]byte{}, + Withdrawals: []*engineprimitives.Withdrawal{ + // The first withdrawal is always for EVM inflation. + st.EVMInflationWithdrawal(), + // Partially withdraw validator 0 by minBalance. + { + Index: 1, + Validator: 1, + Amount: minBalance, + Address: address1, + }, + }, + BaseFeePerGas: math.NewU256(0), + }, + Eth1Data: &types.Eth1Data{}, + Deposits: []*types.Deposit{}, + }, + ) + + // Run the test. + vals, err = sp.Transition(ctx, st, blk) + + // Check outputs and ensure withdrawals in payload is consistent with + // statedb expected withdrawals. + require.NoError(t, err) + require.Zero(t, vals) + + val1BalAfter, err = st.GetBalance(math.U64(1)) + require.NoError(t, err) + require.Equal(t, maxBalance, val1BalAfter) } From a2849f2089d3321d6c63cbdec295e72cce98d054 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 17:31:29 +0100 Subject: [PATCH 13/53] bet --- .../pkg/core/state_processor_staking_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 245278840c..fe381b913e 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -309,7 +309,9 @@ func TestTransitionMaxWithdrawals(t *testing.T) { require.NoError(t, err) require.Equal(t, maxBalance+minBalance, val1BalAfter) - // Process the next block, ensuring that validator 1 is also withdrawn from. + // Process the next block, ensuring that validator 1 is also withdrawn from, + // also ensuring that the state's next withdrawal (validator) index is + // appropriately incremented. blk = buildNextBlock( t, st, @@ -321,7 +323,7 @@ func TestTransitionMaxWithdrawals(t *testing.T) { Withdrawals: []*engineprimitives.Withdrawal{ // The first withdrawal is always for EVM inflation. st.EVMInflationWithdrawal(), - // Partially withdraw validator 0 by minBalance. + // Partially withdraw validator 1 by minBalance. { Index: 1, Validator: 1, @@ -344,6 +346,7 @@ func TestTransitionMaxWithdrawals(t *testing.T) { require.NoError(t, err) require.Zero(t, vals) + // Validator 1 is now withdrawn from. val1BalAfter, err = st.GetBalance(math.U64(1)) require.NoError(t, err) require.Equal(t, maxBalance, val1BalAfter) From 27f74ce502c216969a24730b73cf8ed0f1d90e86 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 17:44:35 +0100 Subject: [PATCH 14/53] inflation per block as gwei --- mod/chain-spec/pkg/chain/chain_spec.go | 8 ++++---- mod/chain-spec/pkg/chain/data.go | 4 ++-- mod/config/pkg/spec/testnet.go | 18 ++++++++++++------ mod/state-transition/pkg/core/state/statedb.go | 5 ++++- .../pkg/core/state_processor_staking.go | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index 03acfae76f..e5b716a276 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -191,8 +191,8 @@ type Spec[ // block. EVMInflationAddress() ExecutionAddressT - // EVMInflationPerBlock returns the amount of native EVM balance to be - // minted to the EVMInflationAddress via a withdrawal every block. + // EVMInflationPerBlock returns the amount of native EVM balance (in Gwei) + // to be minted to the EVMInflationAddress via a withdrawal every block. EVMInflationPerBlock() uint64 } @@ -509,8 +509,8 @@ func (c chainSpec[ return c.Data.EVMInflationAddress } -// EVMInflationPerBlock returns the amount of native EVM balance to be minted to -// the EVMInflationAddress via a withdrawal every block. +// EVMInflationPerBlock returns the amount of native EVM balance (in Gwei) to +// be minted to the EVMInflationAddress via a withdrawal every block. func (c chainSpec[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, ]) EVMInflationPerBlock() uint64 { diff --git a/mod/chain-spec/pkg/chain/data.go b/mod/chain-spec/pkg/chain/data.go index 2a780a87e4..308e563906 100644 --- a/mod/chain-spec/pkg/chain/data.go +++ b/mod/chain-spec/pkg/chain/data.go @@ -152,7 +152,7 @@ type SpecData[ // EVMInflationAddress is the address on the EVM which will receive the // inflation amount of native EVM balance through a withdrawal every block. EVMInflationAddress ExecutionAddressT `mapstructure:"evm-inflation-address"` - // EVMInflationPerBlock is the amount of native EVM balance to be minted - // to the EVMInflationAddress via a withdrawal every block. + // EVMInflationPerBlock is the amount of native EVM balance (in Gwei) to be + // minted to the EVMInflationAddress via a withdrawal every block. EVMInflationPerBlock uint64 `mapstructure:"evm-inflation-per-block"` } diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index 6455b4759e..d627c352ad 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -59,11 +59,11 @@ func BaseSpec() chain.SpecData[ math.Slot, any, ]{ - // // Gwei value constants. - MinDepositAmount: uint64(1e9), - MaxEffectiveBalance: uint64(32e9), - EjectionBalance: uint64(16e9), - EffectiveBalanceIncrement: uint64(1e9), + // Gwei value constants. + MinDepositAmount: 1e9, + MaxEffectiveBalance: 32e9, + EjectionBalance: 16e9, + EffectiveBalanceIncrement: 1e9, // Time parameters constants. SlotsPerEpoch: 32, MinEpochsToInactivityPenalty: 4, @@ -122,6 +122,12 @@ func BaseSpec() chain.SpecData[ FieldElementsPerBlob: 4096, BytesPerBlob: 131072, KZGCommitmentInclusionProofDepth: 17, - CometValues: cmtConsensusParams, + // Comet values. + CometValues: cmtConsensusParams, + // Berachain values. + EVMInflationAddress: common.NewExecutionAddressFromHex( + "0x289274787bAF083C15A45a174b7a8e44F0720660", + ), + EVMInflationPerBlock: 10e9, } } diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 81da4536d6..34c5e36f43 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -310,7 +310,10 @@ func (s *StateDB[ ]) EVMInflationWithdrawal() WithdrawalT { var withdrawal WithdrawalT return withdrawal.New( - 0, 0, s.cs.EVMInflationAddress(), math.U64(s.cs.EVMInflationPerBlock()), + 0, + 0, + s.cs.EVMInflationAddress(), + math.Gwei(s.cs.EVMInflationPerBlock()), ) } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 6a0163fa1b..c28cf192de 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -263,7 +263,7 @@ func (sp *StateProcessor[ if !expectedWithdrawals[0].GetAddress().Equals( sp.cs.EVMInflationAddress(), ) || - expectedWithdrawals[0].GetAmount() != math.U64( + expectedWithdrawals[0].GetAmount() != math.Gwei( sp.cs.EVMInflationPerBlock(), ) { return ErrFirstWithdrawalNotEVMInflation From a1cf677bb90f3040d87703373dbb01dcb00accab Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 18:05:21 +0100 Subject: [PATCH 15/53] e2e test --- mod/config/pkg/spec/testnet.go | 2 +- .../pkg/core/state_processor_genesis.go | 5 +-- testing/e2e/config/defaults.go | 6 ++++ testing/e2e/e2e_startup_test.go | 32 ++++++++++++++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index d627c352ad..e5ab834759 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -126,7 +126,7 @@ func BaseSpec() chain.SpecData[ CometValues: cmtConsensusParams, // Berachain values. EVMInflationAddress: common.NewExecutionAddressFromHex( - "0x289274787bAF083C15A45a174b7a8e44F0720660", + "0x6942069420694206942069420694206942069420", ), EVMInflationPerBlock: 10e9, } diff --git a/mod/state-transition/pkg/core/state_processor_genesis.go b/mod/state-transition/pkg/core/state_processor_genesis.go index 7633ddfa5a..aff9516dc5 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis.go +++ b/mod/state-transition/pkg/core/state_processor_genesis.go @@ -68,7 +68,6 @@ func (sp *StateProcessor[ } // Eth1DepositIndex will be set in processDeposit - if err := st.SetEth1Data( eth1Data.New( common.Root{}, @@ -145,9 +144,7 @@ func (sp *StateProcessor[ return nil, err } - if err = st.SetNextWithdrawalValidatorIndex( - 0, - ); err != nil { + if err = st.SetNextWithdrawalValidatorIndex(0); err != nil { return nil, err } diff --git a/testing/e2e/config/defaults.go b/testing/e2e/config/defaults.go index 5cb40423d0..4ab358c787 100644 --- a/testing/e2e/config/defaults.go +++ b/testing/e2e/config/defaults.go @@ -31,3 +31,9 @@ const ( DepositContractAddress = "0x4242424242424242424242424242424242424242" NumDepositsLoad = 500 ) + +// EVM Inflation. +const ( + EVMInflationAddress = "0x6942069420694206942069420694206942069420" + EVMInflationPerBlockWei = 10e18 +) diff --git a/testing/e2e/e2e_startup_test.go b/testing/e2e/e2e_startup_test.go index 8ec0de8872..8c36da6083 100644 --- a/testing/e2e/e2e_startup_test.go +++ b/testing/e2e/e2e_startup_test.go @@ -21,7 +21,11 @@ package e2e_test import ( + "math/big" + + "github.com/berachain/beacon-kit/testing/e2e/config" "github.com/berachain/beacon-kit/testing/e2e/suite" + gethcommon "github.com/ethereum/go-ethereum/common" ) // BeaconE2ESuite is a suite of tests simulating a fully function beacon-kit @@ -31,8 +35,34 @@ type BeaconKitE2ESuite struct { } // TestBasicStartup tests the basic startup of the beacon-kit network. -// TODO: Should check all clients, opposed to the load balancer. +// TODO: Should check all clients, opposed to just the load balancer. func (s *BeaconKitE2ESuite) TestBasicStartup() { err := s.WaitForFinalizedBlockNumber(10) s.Require().NoError(err) } + +// TestEVMInflation checks that the EVM inflation address receives the correct +// amount of EVM inflation per block. +func (s *BeaconKitE2ESuite) TestEVMInflation() { + evmInflationPerBlockWei, _ := big.NewFloat( + config.EVMInflationPerBlockWei).Int(nil) + + // Check over the next 10 EVM blocks, that after every block, the balance + // of the EVM inflation address increases by EVMInflationPerBlockWei. + for i := int64(1); i <= 10; i++ { + err := s.WaitForFinalizedBlockNumber(uint64(i)) + s.Require().NoError(err) + + balance, err := s.JSONRPCBalancer().BalanceAt( + s.Ctx(), + gethcommon.HexToAddress(config.EVMInflationAddress), + big.NewInt(int64(i)), + ) + s.Require().NoError(err) + s.Require().Equal( + balance.Cmp(new(big.Int).Mul( + evmInflationPerBlockWei, big.NewInt(i)), + ), 0, + ) + } +} From fdb516339d3932be85660a361e4a24e48e0d69c9 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 18:10:00 +0100 Subject: [PATCH 16/53] bet --- testing/e2e/e2e_startup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/e2e/e2e_startup_test.go b/testing/e2e/e2e_startup_test.go index 8c36da6083..a0111848c2 100644 --- a/testing/e2e/e2e_startup_test.go +++ b/testing/e2e/e2e_startup_test.go @@ -56,7 +56,7 @@ func (s *BeaconKitE2ESuite) TestEVMInflation() { balance, err := s.JSONRPCBalancer().BalanceAt( s.Ctx(), gethcommon.HexToAddress(config.EVMInflationAddress), - big.NewInt(int64(i)), + big.NewInt(i), ) s.Require().NoError(err) s.Require().Equal( From 6a3f2823cd8b8d2e45118a1ee6b44745931b1a49 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 18 Nov 2024 19:35:52 +0100 Subject: [PATCH 17/53] bet --- mod/chain-spec/pkg/chain/chain_spec.go | 2 +- mod/chain-spec/pkg/chain/errors.go | 9 +++-- mod/state-transition/pkg/core/core_test.go | 40 ++++++++++--------- .../pkg/core/state_processor_staking.go | 4 +- .../pkg/core/state_processor_staking_test.go | 2 +- testing/e2e/e2e_startup_test.go | 10 ++--- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index e5b716a276..828afae9f4 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -234,7 +234,7 @@ func (c *chainSpec[ DomainTypeT, EpochT, ExecutionAddressT, SlotT, CometBFTConfigT, ]) validate() error { if c.MaxWithdrawalsPerPayload() <= 1 { - return ErrZeroMaxWithdrawalsPerPayload + return ErrInsufficientMaxWithdrawalsPerPayload } // TODO: Add more validation rules here. diff --git a/mod/chain-spec/pkg/chain/errors.go b/mod/chain-spec/pkg/chain/errors.go index 644e055920..6dc55f59ef 100644 --- a/mod/chain-spec/pkg/chain/errors.go +++ b/mod/chain-spec/pkg/chain/errors.go @@ -23,9 +23,10 @@ package chain import "github.com/berachain/beacon-kit/mod/errors" var ( - // ErrZeroMaxWithdrawalsPerPayload is returned when the max withdrawals - // per payload is zero. Must allow at least one for the EVM inflation - // withdrawal, and at least one more for a validator withdrawal per block. - ErrZeroMaxWithdrawalsPerPayload = errors.New( + // ErrInsufficientMaxWithdrawalsPerPayload is returned when the max + // withdrawals per payload less than 2. Must allow at least one for the EVM + // inflation withdrawal, and at least one more for a validator withdrawal + // per block. + ErrInsufficientMaxWithdrawalsPerPayload = errors.New( "max withdrawals per payload must be greater than 1") ) diff --git a/mod/state-transition/pkg/core/core_test.go b/mod/state-transition/pkg/core/core_test.go index a65df0a757..e9f19b0d05 100644 --- a/mod/state-transition/pkg/core/core_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -87,6 +87,26 @@ type ( *engineprimitives.Withdrawal, types.WithdrawalCredentials, ] + + TestStateProcessorT = core.StateProcessor[ + *types.BeaconBlock, + *types.BeaconBlockBody, + *types.BeaconBlockHeader, + *TestBeaconStateT, + *transition.Context, + *types.Deposit, + *types.Eth1Data, + *types.ExecutionPayload, + *types.ExecutionPayloadHeader, + *types.Fork, + *types.ForkData, + *TestKVStoreT, + *types.Validator, + types.Validators, + *engineprimitives.Withdrawal, + engineprimitives.Withdrawals, + types.WithdrawalCredentials, + ] ) type testKVStoreService struct { @@ -166,25 +186,7 @@ func setupState( bytes.B4, math.U64, common.ExecutionAddress, math.U64, any, ], ) ( - *core.StateProcessor[ - *types.BeaconBlock, - *types.BeaconBlockBody, - *types.BeaconBlockHeader, - *TestBeaconStateT, - *transition.Context, - *types.Deposit, - *types.Eth1Data, - *types.ExecutionPayload, - *types.ExecutionPayloadHeader, - *types.Fork, - *types.ForkData, - *TestKVStoreT, - *types.Validator, - types.Validators, - *engineprimitives.Withdrawal, - engineprimitives.Withdrawals, - types.WithdrawalCredentials, - ], + *TestStateProcessorT, *TestBeaconStateT, *transition.Context, ) { diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index c28cf192de..74c9efb7e2 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -275,8 +275,8 @@ func (sp *StateProcessor[ if !wd.Equals(payloadWithdrawals[i]) { return errors.Wrapf( ErrWithdrawalMismatch, - "withdrawals do not match expected %s, got %s", - spew.Sdump(wd), spew.Sdump(payloadWithdrawals[i]), + "withdrawal at index %d does not match expected %s, got %s", + i, spew.Sdump(wd), spew.Sdump(payloadWithdrawals[i]), ) } diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index fe381b913e..52daf4e321 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -317,7 +317,7 @@ func TestTransitionMaxWithdrawals(t *testing.T) { st, &types.BeaconBlockBody{ ExecutionPayload: &types.ExecutionPayload{ - Timestamp: 10, + Timestamp: 11, ExtraData: []byte("testing"), Transactions: [][]byte{}, Withdrawals: []*engineprimitives.Withdrawal{ diff --git a/testing/e2e/e2e_startup_test.go b/testing/e2e/e2e_startup_test.go index a0111848c2..52665490af 100644 --- a/testing/e2e/e2e_startup_test.go +++ b/testing/e2e/e2e_startup_test.go @@ -49,7 +49,7 @@ func (s *BeaconKitE2ESuite) TestEVMInflation() { // Check over the next 10 EVM blocks, that after every block, the balance // of the EVM inflation address increases by EVMInflationPerBlockWei. - for i := int64(1); i <= 10; i++ { + for i := int64(0); i <= 10; i++ { err := s.WaitForFinalizedBlockNumber(uint64(i)) s.Require().NoError(err) @@ -59,10 +59,8 @@ func (s *BeaconKitE2ESuite) TestEVMInflation() { big.NewInt(i), ) s.Require().NoError(err) - s.Require().Equal( - balance.Cmp(new(big.Int).Mul( - evmInflationPerBlockWei, big.NewInt(i)), - ), 0, - ) + s.Require().Zero(balance.Cmp(new(big.Int).Mul( + evmInflationPerBlockWei, big.NewInt(i)), + )) } } From 6fd0c0a17c6911e84d3e8ce5d168c05ed740a5a6 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 14:42:39 +0100 Subject: [PATCH 18/53] remove unneeded checks --- mod/state-transition/pkg/core/errors.go | 10 --------- .../pkg/core/state_processor_staking.go | 22 +++++-------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index fb66ea1414..21b5462d9e 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -81,16 +81,6 @@ var ( // in a block does not match the expected value. ErrNumWithdrawalsMismatch = errors.New("number of withdrawals mismatch") - // ErrNoWithdrawals is returned when a block contains no withdrawals. We - // expect at least the fixed withdrawal for EVM inflation. - ErrNoWithdrawals = errors.New( - "no withdrawals in block, expected at least 1 for EVM inflation") - - // ErrFirstWithdrawalNotEVMInflation is returned when the first withdrawal - // in the block is not the EVM inflation withdrawal. - ErrFirstWithdrawalNotEVMInflation = errors.New( - "first withdrawal is not the EVM inflation withdrawal") - // ErrWithdrawalMismatch is returned when the withdrawals in a payload do // not match the local state's expected value. ErrWithdrawalMismatch = errors.New( diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 74c9efb7e2..8800cad0ba 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -256,19 +256,6 @@ func (sp *StateProcessor[ ) } - // Ensure the EVM inflation withdrawal is the first withdrawal. - if numWithdrawals == 0 { - return ErrNoWithdrawals - } - if !expectedWithdrawals[0].GetAddress().Equals( - sp.cs.EVMInflationAddress(), - ) || - expectedWithdrawals[0].GetAmount() != math.Gwei( - sp.cs.EVMInflationPerBlock(), - ) { - return ErrFirstWithdrawalNotEVMInflation - } - // Compare and process each withdrawal. for i, wd := range expectedWithdrawals { // Ensure the withdrawals match the local state. @@ -317,7 +304,8 @@ func (sp *StateProcessor[ numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { // Next sweep starts after the latest withdrawal's validator index. nextValIndex = - expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1 + (expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1) % + math.ValidatorIndex(totalValidators) } else { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. @@ -325,8 +313,10 @@ func (sp *StateProcessor[ if err != nil { return err } - nextValIndex += math.U64(sp.cs.MaxValidatorsPerWithdrawalsSweep()) + nextValIndex += math.ValidatorIndex( + sp.cs.MaxValidatorsPerWithdrawalsSweep()) + nextValIndex %= math.ValidatorIndex(totalValidators) } - nextValIndex %= math.U64(totalValidators) + return st.SetNextWithdrawalValidatorIndex(nextValIndex) } From c68fcab146450926434dbc5f6c95c2c9051c1a49 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 14:45:24 +0100 Subject: [PATCH 19/53] nit --- .../pkg/core/state_processor_staking.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 8800cad0ba..57a56f7160 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -236,6 +236,7 @@ func (sp *StateProcessor[ body BeaconBlockBodyT, ) error { var ( + nextValidatorIndex math.ValidatorIndex payload = body.GetExecutionPayload() payloadWithdrawals = payload.GetWithdrawals() ) @@ -298,25 +299,23 @@ func (sp *StateProcessor[ } // Update the next validator index to start the next withdrawal sweep. - var nextValIndex math.ValidatorIndex - if numWithdrawals > 1 && - //#nosec:G701 // won't overflow in practice. - numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { + //#nosec:G701 // won't overflow in practice. + if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { // Next sweep starts after the latest withdrawal's validator index. - nextValIndex = + nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) } else { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. - nextValIndex, err = st.GetNextWithdrawalValidatorIndex() + nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() if err != nil { return err } - nextValIndex += math.ValidatorIndex( + nextValidatorIndex += math.ValidatorIndex( sp.cs.MaxValidatorsPerWithdrawalsSweep()) - nextValIndex %= math.ValidatorIndex(totalValidators) + nextValidatorIndex %= math.ValidatorIndex(totalValidators) } - return st.SetNextWithdrawalValidatorIndex(nextValIndex) + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) } From 5517eb9fafe5d02125ccefe6d50f3397ffe6c9ad Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 14:54:29 +0100 Subject: [PATCH 20/53] reduce diff --- mod/state-transition/pkg/core/state/statedb.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 34c5e36f43..45bd704756 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -233,11 +233,6 @@ func (s *StateDB[ // Iterate through indices to find the next validators to withdraw. for range bound { - // Cap the number of withdrawals to the maximum allowed per payload. - if uint64(len(withdrawals)) == s.cs.MaxWithdrawalsPerPayload() { - break - } - validator, err = s.ValidatorByIndex(validatorIndex) if err != nil { return nil, err @@ -293,9 +288,15 @@ func (s *StateDB[ withdrawalIndex++ } + // Cap the number of withdrawals to the maximum allowed per payload. + if uint64(len(withdrawals)) == s.cs.MaxWithdrawalsPerPayload() { + break + } + // Increment the validator index to process the next validator. - validatorIndex++ - validatorIndex %= math.ValidatorIndex(totalValidators) + validatorIndex = (validatorIndex + 1) % math.ValidatorIndex( + totalValidators, + ) } return withdrawals, nil From 4f221e9338487fb7743e37fee65c93b3063d80f9 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 15:20:05 +0100 Subject: [PATCH 21/53] bet --- .../pkg/engine-primitives/mocks/blobs_bundle.mock.go | 2 +- .../mocks/built_execution_payload_env.mock.go | 2 +- .../mocks/payload_attributer.mock.go | 2 +- mod/geth-primitives/pkg/deposit/contract.abigen.go | 2 +- mod/node-api/backend/mocks/availability_store.mock.go | 2 +- .../backend/mocks/beacon_block_header.mock.go | 2 +- mod/node-api/backend/mocks/beacon_state.mock.go | 2 +- mod/node-api/backend/mocks/block_store.mock.go | 2 +- mod/node-api/backend/mocks/deposit_store.mock.go | 2 +- mod/node-api/backend/mocks/node.mock.go | 2 +- mod/node-api/backend/mocks/state_processor.mock.go | 2 +- mod/node-api/backend/mocks/storage_backend.mock.go | 2 +- mod/node-api/backend/mocks/validator.mock.go | 2 +- mod/node-api/backend/mocks/withdrawal.mock.go | 2 +- .../backend/mocks/withdrawal_credentials.mock.go | 2 +- mod/node-core/pkg/components/chain_spec.go | 11 +++++++---- .../pkg/services/registry/mocks/basic.mock.go | 2 +- .../pkg/services/registry/mocks/dispatcher.mock.go | 2 +- .../services/registry/mocks/registry_option.mock.go | 2 +- mod/primitives/pkg/crypto/mocks/bls_signer.mock.go | 2 +- .../pkg/core/mocks/execution_engine.mock.go | 2 +- mod/storage/pkg/interfaces/mocks/db.mock.go | 2 +- mod/storage/pkg/pruner/mocks/beacon_block.mock.go | 2 +- mod/storage/pkg/pruner/mocks/block_event.mock.go | 2 +- mod/storage/pkg/pruner/mocks/prunable.mock.go | 2 +- mod/storage/pkg/pruner/mocks/pruner.mock.go | 2 +- 26 files changed, 32 insertions(+), 29 deletions(-) diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go index ea12e6f259..67afc56b70 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go index eddc7753b4..df3a200894 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go index 4eaed7cdd2..0edbc8091a 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/geth-primitives/pkg/deposit/contract.abigen.go b/mod/geth-primitives/pkg/deposit/contract.abigen.go index 5d121d9edf..dab3abd28c 100644 --- a/mod/geth-primitives/pkg/deposit/contract.abigen.go +++ b/mod/geth-primitives/pkg/deposit/contract.abigen.go @@ -32,7 +32,7 @@ var ( // BeaconDepositContractMetaData contains all meta data concerning the BeaconDepositContract contract. var BeaconDepositContractMetaData = &bind.MetaData{ ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"allowDeposit\",\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"number\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"cancelOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"completeOwnershipHandover\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"withdrawal_credentials\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositAuth\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositCount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"result\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ownershipHandoverExpiresAt\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"result\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"requestOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"event\",\"name\":\"Deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"credentials\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"index\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverCanceled\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverRequested\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"oldOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyInitialized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositNotMultipleOfGwei\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositValueTooHigh\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InsufficientDeposit\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidCredentialsLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidPubKeyLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidSignatureLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NewOwnerIsZeroAddress\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NoHandoverRequest\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"Unauthorized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnauthorizedDeposit\",\"inputs\":[]}]", - Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea26469706673582212209dfb8e5ead8b23553bd4102b9e66cae17b890a520a2c3b480698309f19d2819664736f6c634300081a0033", + Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea2646970667358221220b08e6fc3b9c94a2f65976bacf514e878deea80490a6ebe3959e6047117451a1464736f6c634300081a0033", } // BeaconDepositContractABI is the input ABI used to generate the binding from. diff --git a/mod/node-api/backend/mocks/availability_store.mock.go b/mod/node-api/backend/mocks/availability_store.mock.go index f06c33c1b2..20eb2e5b6e 100644 --- a/mod/node-api/backend/mocks/availability_store.mock.go +++ b/mod/node-api/backend/mocks/availability_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_block_header.mock.go b/mod/node-api/backend/mocks/beacon_block_header.mock.go index e12e0ea345..eb238bac1e 100644 --- a/mod/node-api/backend/mocks/beacon_block_header.mock.go +++ b/mod/node-api/backend/mocks/beacon_block_header.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_state.mock.go b/mod/node-api/backend/mocks/beacon_state.mock.go index 017979cb76..6d9fb92e2b 100644 --- a/mod/node-api/backend/mocks/beacon_state.mock.go +++ b/mod/node-api/backend/mocks/beacon_state.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/block_store.mock.go b/mod/node-api/backend/mocks/block_store.mock.go index 681510ecb2..df70ab86b5 100644 --- a/mod/node-api/backend/mocks/block_store.mock.go +++ b/mod/node-api/backend/mocks/block_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/deposit_store.mock.go b/mod/node-api/backend/mocks/deposit_store.mock.go index 1375b8a0d0..32e8381059 100644 --- a/mod/node-api/backend/mocks/deposit_store.mock.go +++ b/mod/node-api/backend/mocks/deposit_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/node.mock.go b/mod/node-api/backend/mocks/node.mock.go index 1c4e445533..b806434428 100644 --- a/mod/node-api/backend/mocks/node.mock.go +++ b/mod/node-api/backend/mocks/node.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/state_processor.mock.go b/mod/node-api/backend/mocks/state_processor.mock.go index e96d5920cd..ac2b23b03a 100644 --- a/mod/node-api/backend/mocks/state_processor.mock.go +++ b/mod/node-api/backend/mocks/state_processor.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/storage_backend.mock.go b/mod/node-api/backend/mocks/storage_backend.mock.go index 61273f4174..dd28160b49 100644 --- a/mod/node-api/backend/mocks/storage_backend.mock.go +++ b/mod/node-api/backend/mocks/storage_backend.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/validator.mock.go b/mod/node-api/backend/mocks/validator.mock.go index 29344cbac0..3f904a98e8 100644 --- a/mod/node-api/backend/mocks/validator.mock.go +++ b/mod/node-api/backend/mocks/validator.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal.mock.go b/mod/node-api/backend/mocks/withdrawal.mock.go index 8f51b01292..654d5f85e2 100644 --- a/mod/node-api/backend/mocks/withdrawal.mock.go +++ b/mod/node-api/backend/mocks/withdrawal.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go index f405c2352e..5189b3b6b8 100644 --- a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go +++ b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/components/chain_spec.go b/mod/node-core/pkg/components/chain_spec.go index 4f2b7a85aa..4bb7128ff8 100644 --- a/mod/node-core/pkg/components/chain_spec.go +++ b/mod/node-core/pkg/components/chain_spec.go @@ -28,10 +28,11 @@ import ( ) const ( - ChainSpecTypeEnvVar = "CHAIN_SPEC" - DevnetChainSpecType = "devnet" - BetnetChainSpecType = "betnet" - BoonetChainSpecType = "boonet" + ChainSpecTypeEnvVar = "CHAIN_SPEC" + DevnetChainSpecType = "devnet" + BetnetChainSpecType = "betnet" + BoonetChainSpecType = "boonet" + TestnetChainSpecType = "testnet" ) // ProvideChainSpec provides the chain spec based on the environment variable. @@ -49,6 +50,8 @@ func ProvideChainSpec() (common.ChainSpec, error) { chainSpec, err = spec.BetnetChainSpec() case BoonetChainSpecType: chainSpec, err = spec.BoonetChainSpec() + case TestnetChainSpecType: + fallthrough default: chainSpec, err = spec.TestnetChainSpec() } diff --git a/mod/node-core/pkg/services/registry/mocks/basic.mock.go b/mod/node-core/pkg/services/registry/mocks/basic.mock.go index bed8ddb1b1..5636cc2499 100644 --- a/mod/node-core/pkg/services/registry/mocks/basic.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/basic.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go index 71cf4e2ed5..8c02d26466 100644 --- a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go index b13e2d5ddf..cf55bbcda8 100644 --- a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go index ec64c1df0f..4abffe8962 100644 --- a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go +++ b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go index 025e60a881..c0ddbae4ab 100644 --- a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go +++ b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/interfaces/mocks/db.mock.go b/mod/storage/pkg/interfaces/mocks/db.mock.go index bfeafb3a2d..f9cdef39a7 100644 --- a/mod/storage/pkg/interfaces/mocks/db.mock.go +++ b/mod/storage/pkg/interfaces/mocks/db.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go index b057bd7427..ba68c5bf2d 100644 --- a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go +++ b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/block_event.mock.go b/mod/storage/pkg/pruner/mocks/block_event.mock.go index 7d30166e8a..5d2d1891ca 100644 --- a/mod/storage/pkg/pruner/mocks/block_event.mock.go +++ b/mod/storage/pkg/pruner/mocks/block_event.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/prunable.mock.go b/mod/storage/pkg/pruner/mocks/prunable.mock.go index 1f86b9eacc..0b84e1e0b4 100644 --- a/mod/storage/pkg/pruner/mocks/prunable.mock.go +++ b/mod/storage/pkg/pruner/mocks/prunable.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/pruner.mock.go b/mod/storage/pkg/pruner/mocks/pruner.mock.go index 8c2cca5c42..77e354f31e 100644 --- a/mod/storage/pkg/pruner/mocks/pruner.mock.go +++ b/mod/storage/pkg/pruner/mocks/pruner.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.47.0. DO NOT EDIT. +// Code generated by mockery v2.48.0. DO NOT EDIT. package mocks From c498b533c6908ae42a0ef467b1fa4221de631dcb Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 16:12:30 +0100 Subject: [PATCH 22/53] Testnet variable --- mod/config/pkg/spec/constants.go | 6 +++--- mod/config/pkg/spec/testnet.go | 2 +- .../pkg/core/state_processor_genesis_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mod/config/pkg/spec/constants.go b/mod/config/pkg/spec/constants.go index 2b0cea5548..cf978fdbd2 100644 --- a/mod/config/pkg/spec/constants.go +++ b/mod/config/pkg/spec/constants.go @@ -22,13 +22,13 @@ package spec const ( - // BoonetEth1ChainID is the chain ID for the local devnet. + // BoonetEth1ChainID is the chain ID for a local devnet. BoonetEth1ChainID uint64 = 80000 - // BetnetEth1ChainID is the chain ID for the local devnet. + // BetnetEth1ChainID is the chain ID for a local devnet. BetnetEth1ChainID uint64 = 80088 - // DevnetEth1ChainID is the chain ID for the local devnet. + // DevnetEth1ChainID is the chain ID for a local devnet. DevnetEth1ChainID uint64 = 80087 // TestnetEth1ChainID is the chain ID for the bArtio testnet. diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index e5ab834759..164f5233fc 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -28,7 +28,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" ) -// TestnetChainSpec is the ChainSpec for the localnet. +// TestnetChainSpec is the ChainSpec for the bArtio testnet. func TestnetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, diff --git a/mod/state-transition/pkg/core/state_processor_genesis_test.go b/mod/state-transition/pkg/core/state_processor_genesis_test.go index 389b9c1078..5f3f8031c6 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis_test.go +++ b/mod/state-transition/pkg/core/state_processor_genesis_test.go @@ -128,7 +128,7 @@ func checkValidatorNonBartio( } func TestInitializeBartio(t *testing.T) { - cs := setupChain(t, "testnet") + cs := setupChain(t, components.TestnetChainSpecType) sp, st, _ := setupState(t, cs) var ( From b60f6cd7fec19063640e71245c7197012b2df215 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 16:15:29 +0100 Subject: [PATCH 23/53] gen --- mod/geth-primitives/pkg/deposit/contract.abigen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/geth-primitives/pkg/deposit/contract.abigen.go b/mod/geth-primitives/pkg/deposit/contract.abigen.go index dab3abd28c..5d121d9edf 100644 --- a/mod/geth-primitives/pkg/deposit/contract.abigen.go +++ b/mod/geth-primitives/pkg/deposit/contract.abigen.go @@ -32,7 +32,7 @@ var ( // BeaconDepositContractMetaData contains all meta data concerning the BeaconDepositContract contract. var BeaconDepositContractMetaData = &bind.MetaData{ ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"allowDeposit\",\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"number\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"cancelOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"completeOwnershipHandover\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"withdrawal_credentials\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositAuth\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositCount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"result\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ownershipHandoverExpiresAt\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"result\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"requestOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"event\",\"name\":\"Deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"credentials\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"index\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverCanceled\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverRequested\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"oldOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyInitialized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositNotMultipleOfGwei\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositValueTooHigh\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InsufficientDeposit\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidCredentialsLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidPubKeyLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidSignatureLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NewOwnerIsZeroAddress\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NoHandoverRequest\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"Unauthorized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnauthorizedDeposit\",\"inputs\":[]}]", - Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea2646970667358221220b08e6fc3b9c94a2f65976bacf514e878deea80490a6ebe3959e6047117451a1464736f6c634300081a0033", + Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea26469706673582212209dfb8e5ead8b23553bd4102b9e66cae17b890a520a2c3b480698309f19d2819664736f6c634300081a0033", } // BeaconDepositContractABI is the input ABI used to generate the binding from. From 2e96a53070e7dfecb392043f24c232ec2adff6d9 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 16:33:10 +0100 Subject: [PATCH 24/53] details of berachain values --- mod/config/pkg/spec/testnet.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index 164f5233fc..a289f24a79 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -125,9 +125,13 @@ func BaseSpec() chain.SpecData[ // Comet values. CometValues: cmtConsensusParams, // Berachain values. + // + // Expected address of the BGT contract on the bArtio testnet. EVMInflationAddress: common.NewExecutionAddressFromHex( - "0x6942069420694206942069420694206942069420", + "0x289274787bAF083C15A45a174b7a8e44F0720660", ), + // EVM inflation of 10 BERA per block minting to back potential BGT + // token redemptions for BERA (sets the upper bound on ) EVMInflationPerBlock: 10e9, } } From 13631c4a0b6b787ac6fdbb21ef15e5bc999e6bee Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 19 Nov 2024 16:40:34 +0100 Subject: [PATCH 25/53] nit --- mod/config/pkg/spec/testnet.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index a289f24a79..a3a76b3e97 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -131,7 +131,8 @@ func BaseSpec() chain.SpecData[ "0x289274787bAF083C15A45a174b7a8e44F0720660", ), // EVM inflation of 10 BERA per block minting to back potential BGT - // token redemptions for BERA (sets the upper bound on ) + // token redemptions for BERA (sets the upper bound on amount of BGT + // that can be redeemed for BERA). EVMInflationPerBlock: 10e9, } } From b64cf6aa431f627092dc1b5a64735f0446d7afa0 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 11:55:04 +0100 Subject: [PATCH 26/53] do not modify next withdrawal validator index if len == 0 --- mod/state-transition/pkg/core/state/statedb.go | 2 +- mod/state-transition/pkg/core/state_processor_staking.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 45bd704756..0be0ca0046 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -233,7 +233,7 @@ func (s *StateDB[ // Iterate through indices to find the next validators to withdraw. for range bound { - validator, err = s.ValidatorByIndex(validatorIndex) + validator, err = s.ValidatorByIndex(validatorIndex) // 0 if err != nil { return nil, err } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 0cfef29850..3978b6a059 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -306,7 +306,8 @@ func (sp *StateProcessor[ nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) - } else { + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) + } else if numWithdrawals > 1 { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() @@ -316,7 +317,8 @@ func (sp *StateProcessor[ nextValidatorIndex += math.ValidatorIndex( sp.cs.MaxValidatorsPerWithdrawalsSweep()) nextValidatorIndex %= math.ValidatorIndex(totalValidators) + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) } - return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) + return nil } From b018f7846b32f6280025f73ac569ce9f21f7d2b7 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 12:42:57 +0100 Subject: [PATCH 27/53] nit --- mod/state-transition/pkg/core/state/statedb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 0be0ca0046..45bd704756 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -233,7 +233,7 @@ func (s *StateDB[ // Iterate through indices to find the next validators to withdraw. for range bound { - validator, err = s.ValidatorByIndex(validatorIndex) // 0 + validator, err = s.ValidatorByIndex(validatorIndex) if err != nil { return nil, err } From 380ac3d8120ff126900dcdd7ab1faf548d0e5153 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 15:38:44 +0100 Subject: [PATCH 28/53] explicitly ensure withdrawal 0 has no state update --- mod/config/pkg/spec/boonet.go | 8 +++++ mod/config/pkg/spec/testnet.go | 10 +++---- mod/state-transition/pkg/core/errors.go | 4 +++ .../pkg/core/state_processor_staking.go | 30 ++++++++++--------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/mod/config/pkg/spec/boonet.go b/mod/config/pkg/spec/boonet.go index 36fe46083e..ff5e7dc41a 100644 --- a/mod/config/pkg/spec/boonet.go +++ b/mod/config/pkg/spec/boonet.go @@ -36,5 +36,13 @@ func BoonetChainSpec() (chain.Spec[ ], error) { testnetSpec := BaseSpec() testnetSpec.DepositEth1ChainID = BoonetEth1ChainID + + // BGT contract address + testnetSpec.EVMInflationAddress = common.NewExecutionAddressFromHex( + "0x289274787bAF083C15A45a174b7a8e44F0720660", + ) + // 2.5 BERA per block minting + testnetSpec.EVMInflationPerBlock = 2.5e9 + return chain.NewChainSpec(testnetSpec) } diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index a3a76b3e97..4d53bf2965 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -41,6 +41,8 @@ func TestnetChainSpec() (chain.Spec[ return chain.NewChainSpec(testnetSpec) } +// BaseSpec returns a chain spec with default values. +// //nolint:mnd // bet. func BaseSpec() chain.SpecData[ common.DomainType, @@ -126,13 +128,11 @@ func BaseSpec() chain.SpecData[ CometValues: cmtConsensusParams, // Berachain values. // - // Expected address of the BGT contract on the bArtio testnet. + // EVM inflation per block will be minted to this address. EVMInflationAddress: common.NewExecutionAddressFromHex( - "0x289274787bAF083C15A45a174b7a8e44F0720660", + "0x6942069420694206942069420694206942069420", ), - // EVM inflation of 10 BERA per block minting to back potential BGT - // token redemptions for BERA (sets the upper bound on amount of BGT - // that can be redeemed for BERA). + // EVM inflation of 10 BERA per block minting. EVMInflationPerBlock: 10e9, } } diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index d40f7a47a6..09ffbfb5f5 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -73,6 +73,10 @@ var ( // in a block exceeds the maximum allowed. ErrExceedMaximumWithdrawals = errors.New("exceeds maximum withdrawals") + // ErrZeroWithdrawals is returned when the number of withdrawals in a + // block is zero. The EVM inflation withdrawal is always expected. + ErrZeroWithdrawals = errors.New("zero withdrawals") + // ErrNumWithdrawalsMismatch is returned when the number of withdrawals // in a block does not match the expected value. ErrNumWithdrawalsMismatch = errors.New("number of withdrawals mismatch") diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 3978b6a059..144f0a3478 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -248,13 +248,16 @@ func (sp *StateProcessor[ return err } numWithdrawals := len(expectedWithdrawals) + if numWithdrawals == 0 { + return ErrZeroWithdrawals + } // Ensure the expected and payload withdrawals have the same length. if numWithdrawals != len(payloadWithdrawals) { return errors.Wrapf( ErrNumWithdrawalsMismatch, "withdrawals do not match expected length %d, got %d", - len(expectedWithdrawals), len(payloadWithdrawals), + numWithdrawals, len(payloadWithdrawals), ) } @@ -283,15 +286,16 @@ func (sp *StateProcessor[ } } - // Update the next withdrawal index if this block contained withdrawals - // (excluding the EVM inflation withdrawal). - if numWithdrawals > 1 { - // Next sweep starts after the latest withdrawal's validator index. - if err = st.SetNextWithdrawalIndex( - (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), - ); err != nil { - return err - } + // If there is only the EVM inflation withdrawal, no state update is needed. + if numWithdrawals == 1 { + return nil + } + + // Next sweep starts after the latest withdrawal's validator index. + if err = st.SetNextWithdrawalIndex( + (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), + ); err != nil { + return err } totalValidators, err := st.GetTotalValidators() @@ -306,8 +310,7 @@ func (sp *StateProcessor[ nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) - return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) - } else if numWithdrawals > 1 { + } else { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() @@ -317,8 +320,7 @@ func (sp *StateProcessor[ nextValidatorIndex += math.ValidatorIndex( sp.cs.MaxValidatorsPerWithdrawalsSweep()) nextValidatorIndex %= math.ValidatorIndex(totalValidators) - return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) } - return nil + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) } From 4ade0668431c023c19a6b74011f01e57369ac31e Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 15:47:41 +0100 Subject: [PATCH 29/53] use constants for inflation withdrawal --- .../pkg/core/state/constants.go | 35 +++++++++++++++++++ .../pkg/core/state/statedb.go | 4 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 mod/state-transition/pkg/core/state/constants.go diff --git a/mod/state-transition/pkg/core/state/constants.go b/mod/state-transition/pkg/core/state/constants.go new file mode 100644 index 0000000000..ec8f0b062a --- /dev/null +++ b/mod/state-transition/pkg/core/state/constants.go @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package state + +import "math" + +const ( + // EVMInflationWithdrawalIndex is the fixed withdrawal index to be used for + // the EVM inflation withdrawal in every block. It should remain unused + // during processing. + EVMInflationWithdrawalIndex = math.MaxUint64 + + // EVMInflationWithdrawalValidatorIndex is the fixed validator index to be + // used for the EVM inflation withdrawal in every block. It should remain + // unused during processing. + EVMInflationWithdrawalValidatorIndex = math.MaxUint64 +) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 45bd704756..8a2913b119 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -311,8 +311,8 @@ func (s *StateDB[ ]) EVMInflationWithdrawal() WithdrawalT { var withdrawal WithdrawalT return withdrawal.New( - 0, - 0, + EVMInflationWithdrawalIndex, + EVMInflationWithdrawalValidatorIndex, s.cs.EVMInflationAddress(), math.Gwei(s.cs.EVMInflationPerBlock()), ) From c3fd4d33393b9793a25afd2c7ee090114a7f89a9 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 16:30:39 +0100 Subject: [PATCH 30/53] enforce first is inflation wd --- mod/config/pkg/spec/boonet.go | 9 +++++++-- mod/state-transition/pkg/core/errors.go | 8 +++++++- mod/state-transition/pkg/core/interfaces.go | 1 + mod/state-transition/pkg/core/state_processor_staking.go | 7 +++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/mod/config/pkg/spec/boonet.go b/mod/config/pkg/spec/boonet.go index ff5e7dc41a..55db1e475b 100644 --- a/mod/config/pkg/spec/boonet.go +++ b/mod/config/pkg/spec/boonet.go @@ -35,13 +35,18 @@ func BoonetChainSpec() (chain.Spec[ any, ], error) { testnetSpec := BaseSpec() + + // Chain ID is 80000. testnetSpec.DepositEth1ChainID = BoonetEth1ChainID - // BGT contract address + // BGT contract address. testnetSpec.EVMInflationAddress = common.NewExecutionAddressFromHex( "0x289274787bAF083C15A45a174b7a8e44F0720660", ) - // 2.5 BERA per block minting + + // 2.5 BERA per block minting. + // + // TODO: determine correct value for boonet upgrade. testnetSpec.EVMInflationPerBlock = 2.5e9 return chain.NewChainSpec(testnetSpec) diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index 09ffbfb5f5..40e0feec54 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -74,13 +74,19 @@ var ( ErrExceedMaximumWithdrawals = errors.New("exceeds maximum withdrawals") // ErrZeroWithdrawals is returned when the number of withdrawals in a - // block is zero. The EVM inflation withdrawal is always expected. + // block is zero. At least the EVM inflation withdrawal is always expected. ErrZeroWithdrawals = errors.New("zero withdrawals") // ErrNumWithdrawalsMismatch is returned when the number of withdrawals // in a block does not match the expected value. ErrNumWithdrawalsMismatch = errors.New("number of withdrawals mismatch") + // ErrFirstWithdrawlNotEVMInflation is returned when the first withdrawal + // in a block is not the EVM inflation withdrawal. + ErrFirstWithdrawlNotEVMInflation = errors.New( + "first withdrawal is not the EVM inflation withdrawal", + ) + // ErrWithdrawalMismatch is returned when the withdrawals in a payload do // not match the local state's expected value. ErrWithdrawalMismatch = errors.New( diff --git a/mod/state-transition/pkg/core/interfaces.go b/mod/state-transition/pkg/core/interfaces.go index 6631e65374..c5ff805492 100644 --- a/mod/state-transition/pkg/core/interfaces.go +++ b/mod/state-transition/pkg/core/interfaces.go @@ -177,5 +177,6 @@ type ReadOnlyEth1Data[Eth1DataT, ExecutionPayloadHeaderT any] interface { // ReadOnlyWithdrawals only has read access to withdrawal methods. type ReadOnlyWithdrawals[WithdrawalT any] interface { + EVMInflationWithdrawal() WithdrawalT ExpectedWithdrawals() ([]WithdrawalT, error) } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 144f0a3478..02f3ddb20f 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -272,9 +272,12 @@ func (sp *StateProcessor[ ) } - // The first withdrawal is the EVM inflation withdrawal. No processing - // is needed. + // The first withdrawal is the EVM inflation withdrawal. Aside from + // simple validation, no processing to the state is needed. if i == 0 { + if !wd.Equals(st.EVMInflationWithdrawal()) { + return ErrFirstWithdrawlNotEVMInflation + } continue } From d27d72eb2129901f169c40f7fdb983da50c06691 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 19:24:43 +0100 Subject: [PATCH 31/53] bet --- mod/config/pkg/spec/boonet.go | 7 +++++++ mod/config/pkg/spec/testnet.go | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mod/config/pkg/spec/boonet.go b/mod/config/pkg/spec/boonet.go index 55db1e475b..95976f79fa 100644 --- a/mod/config/pkg/spec/boonet.go +++ b/mod/config/pkg/spec/boonet.go @@ -49,5 +49,12 @@ func BoonetChainSpec() (chain.Spec[ // TODO: determine correct value for boonet upgrade. testnetSpec.EVMInflationPerBlock = 2.5e9 + // MaxValidatorsPerWithdrawalsSweep is 43 because we expect at least 46 + // validators in the total validators set. We choose a prime number smaller + // than the minimum amount of total validators possible. + // + // TODO: Determine correct value for boonet upgrade. + testnetSpec.MaxValidatorsPerWithdrawalsSweep = 43 + return chain.NewChainSpec(testnetSpec) } diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index 4d53bf2965..ad71c356f7 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -126,13 +126,5 @@ func BaseSpec() chain.SpecData[ KZGCommitmentInclusionProofDepth: 17, // Comet values. CometValues: cmtConsensusParams, - // Berachain values. - // - // EVM inflation per block will be minted to this address. - EVMInflationAddress: common.NewExecutionAddressFromHex( - "0x6942069420694206942069420694206942069420", - ), - // EVM inflation of 10 BERA per block minting. - EVMInflationPerBlock: 10e9, } } From 115a48d2d3cc5d20d77f26a4fdf104efc7e559d7 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 19:35:54 +0100 Subject: [PATCH 32/53] bet --- mod/node-core/pkg/components/interfaces.go | 1 + mod/state-transition/pkg/core/errors.go | 4 ++-- mod/state-transition/pkg/core/state_processor_staking.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/node-core/pkg/components/interfaces.go b/mod/node-core/pkg/components/interfaces.go index a5687910ba..9b51849e84 100644 --- a/mod/node-core/pkg/components/interfaces.go +++ b/mod/node-core/pkg/components/interfaces.go @@ -1081,6 +1081,7 @@ type ( // ReadOnlyWithdrawals only has read access to withdrawal methods. ReadOnlyWithdrawals[WithdrawalT any] interface { + EVMInflationWithdrawal() WithdrawalT ExpectedWithdrawals() ([]WithdrawalT, error) } ) diff --git a/mod/state-transition/pkg/core/errors.go b/mod/state-transition/pkg/core/errors.go index 40e0feec54..645171b469 100644 --- a/mod/state-transition/pkg/core/errors.go +++ b/mod/state-transition/pkg/core/errors.go @@ -81,9 +81,9 @@ var ( // in a block does not match the expected value. ErrNumWithdrawalsMismatch = errors.New("number of withdrawals mismatch") - // ErrFirstWithdrawlNotEVMInflation is returned when the first withdrawal + // ErrFirstWithdrawalNotEVMInflation is returned when the first withdrawal // in a block is not the EVM inflation withdrawal. - ErrFirstWithdrawlNotEVMInflation = errors.New( + ErrFirstWithdrawalNotEVMInflation = errors.New( "first withdrawal is not the EVM inflation withdrawal", ) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 02f3ddb20f..a2463057d5 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -276,7 +276,7 @@ func (sp *StateProcessor[ // simple validation, no processing to the state is needed. if i == 0 { if !wd.Equals(st.EVMInflationWithdrawal()) { - return ErrFirstWithdrawlNotEVMInflation + return ErrFirstWithdrawalNotEVMInflation } continue } From ed6c7ca52021513c3770377a34339d2ffb573546 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 20:19:29 +0100 Subject: [PATCH 33/53] bit --- mod/state-transition/pkg/core/state_processor.go | 2 +- mod/state-transition/pkg/core/state_processor_staking.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor.go b/mod/state-transition/pkg/core/state_processor.go index 4a4a050509..7602b961bf 100644 --- a/mod/state-transition/pkg/core/state_processor.go +++ b/mod/state-transition/pkg/core/state_processor.go @@ -301,7 +301,7 @@ func (sp *StateProcessor[ return err } - if err := sp.processWithdrawals(st, blk.GetBody()); err != nil { + if err := sp.processWithdrawals(st, blk); err != nil { return err } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index a2463057d5..f359e1af27 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -230,13 +230,14 @@ func (sp *StateProcessor[ // //nolint:lll func (sp *StateProcessor[ - _, BeaconBlockBodyT, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, + BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) processWithdrawals( st BeaconStateT, - body BeaconBlockBodyT, + blk BeaconBlockT, ) error { // Dequeue and verify the logs. var ( + body = blk.GetBody() nextValidatorIndex math.ValidatorIndex payload = body.GetExecutionPayload() payloadWithdrawals = payload.GetWithdrawals() From a84d097acef9034e7b56951cc4218ca53edc54c2 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 20:50:15 +0100 Subject: [PATCH 34/53] special cases --- .../pkg/core/state/constants.go | 14 +++++ .../pkg/core/state/statedb.go | 20 +++++- .../pkg/core/state_processor_staking.go | 61 ++++++++++++++----- 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/mod/state-transition/pkg/core/state/constants.go b/mod/state-transition/pkg/core/state/constants.go index ec8f0b062a..72adcd415d 100644 --- a/mod/state-transition/pkg/core/state/constants.go +++ b/mod/state-transition/pkg/core/state/constants.go @@ -33,3 +33,17 @@ const ( // unused during processing. EVMInflationWithdrawalValidatorIndex = math.MaxUint64 ) + +// Boonet special case for emergency minting of EVM tokens. +const ( + // EVMMintingSlot is the slot at which we force a single withdrawal to + // mint EVMMintingAmount EVM tokens to EVMMintingAddress. No other + // withdrawals are inserted at this slot. + EVMMintingSlot uint64 = 69420 + + // EVMMintingAddress is the address at which we mint EVM tokens to. + EVMMintingAddress = "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B" + + // EVMMintingAmount is the amount of EVM tokens to mint. + EVMMintingAmount uint64 = 530000000000000000 +) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 8a2913b119..028ad52a00 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -202,14 +202,30 @@ func (s *StateDB[ withdrawal WithdrawalT ) - // The first withdrawal is fixed to be the EVM inflation withdrawal. - withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) + if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // The first withdrawal is fixed to be the EVM inflation withdrawal. + withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) + } slot, err := s.GetSlot() if err != nil { return nil, err } + if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // Slot used to emergency mint EVM tokens. + if slot.Unwrap() == EVMMintingSlot { + var withdrawal WithdrawalT + withdrawals = append(withdrawals, withdrawal.New( + 0, // NOT USED + 0, // NOT USED + common.NewExecutionAddressFromHex(EVMMintingAddress), + math.Gwei(EVMMintingAmount), + )) + return withdrawals, nil + } + } + epoch := math.Epoch(slot.Unwrap() / s.cs.SlotsPerEpoch()) withdrawalIndex, err := s.GetNextWithdrawalIndex() diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index f359e1af27..8009921725 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -29,6 +29,7 @@ import ( "github.com/berachain/beacon-kit/mod/primitives/pkg/common" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/mod/primitives/pkg/version" + "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/state" "github.com/davecgh/go-spew/spew" ) @@ -249,8 +250,11 @@ func (sp *StateProcessor[ return err } numWithdrawals := len(expectedWithdrawals) - if numWithdrawals == 0 { - return ErrZeroWithdrawals + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // Enforce that there is at least one withdrawal for EVM inflation. + if numWithdrawals == 0 { + return ErrZeroWithdrawals + } } // Ensure the expected and payload withdrawals have the same length. @@ -262,6 +266,24 @@ func (sp *StateProcessor[ ) } + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // Slot used to emergency mint EVM tokens. + slot := blk.GetSlot() + if slot.Unwrap() == state.EVMMintingSlot { + // Sanity check. + wd := expectedWithdrawals[0] + if !wd.Equals(payloadWithdrawals[0]) { + return fmt.Errorf( + "minting withdrawal does not match expected %s, got %s", + spew.Sdump(wd), spew.Sdump(payloadWithdrawals[0]), + ) + } + + // No processing needed. + return nil + } + } + // Compare and process each withdrawal. for i, wd := range expectedWithdrawals { // Ensure the withdrawals match the local state. @@ -273,13 +295,15 @@ func (sp *StateProcessor[ ) } - // The first withdrawal is the EVM inflation withdrawal. Aside from - // simple validation, no processing to the state is needed. - if i == 0 { - if !wd.Equals(st.EVMInflationWithdrawal()) { - return ErrFirstWithdrawalNotEVMInflation + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // The first withdrawal is the EVM inflation withdrawal. Aside from + // simple validation, no processing to the state is needed. + if i == 0 { + if !wd.Equals(st.EVMInflationWithdrawal()) { + return ErrFirstWithdrawalNotEVMInflation + } + continue } - continue } // Process the validator withdrawal. @@ -290,9 +314,12 @@ func (sp *StateProcessor[ } } - // If there is only the EVM inflation withdrawal, no state update is needed. - if numWithdrawals == 1 { - return nil + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + // If there is only the EVM inflation withdrawal, no state update is + // needed. + if numWithdrawals == 1 { + return nil + } } // Next sweep starts after the latest withdrawal's validator index. @@ -311,9 +338,15 @@ func (sp *StateProcessor[ //#nosec:G701 // won't overflow in practice. if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { // Next sweep starts after the latest withdrawal's validator index. - nextValidatorIndex = - (expectedWithdrawals[numWithdrawals-1].GetValidatorIndex() + 1) % - math.ValidatorIndex(totalValidators) + if sp.cs.DepositEth1ChainID() == spec.BartioChainID { + // For backwards compatibility with bArtio. + nextValidatorIndex = + (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1) % + math.ValidatorIndex(totalValidators) + } else { + nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1]. + GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) + } } else { // Advance sweep by the max length of the sweep if there was not a full // set of withdrawals. From d7c6589798a8b5b5ea001bc65b44135c121f7894 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 26 Nov 2024 20:55:00 +0100 Subject: [PATCH 35/53] gen --- .../backend/mocks/beacon_state.mock.go | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/mod/node-api/backend/mocks/beacon_state.mock.go b/mod/node-api/backend/mocks/beacon_state.mock.go index ef3004fd8d..99c0d2c4b9 100644 --- a/mod/node-api/backend/mocks/beacon_state.mock.go +++ b/mod/node-api/backend/mocks/beacon_state.mock.go @@ -26,6 +26,53 @@ func (_m *BeaconState[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, Fo return &BeaconState_Expecter[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]{mock: &_m.Mock} } +// EVMInflationWithdrawal provides a mock function with given fields: +func (_m *BeaconState[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) EVMInflationWithdrawal() WithdrawalT { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EVMInflationWithdrawal") + } + + var r0 WithdrawalT + if rf, ok := ret.Get(0).(func() WithdrawalT); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(WithdrawalT) + } + } + + return r0 +} + +// BeaconState_EVMInflationWithdrawal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EVMInflationWithdrawal' +type BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT any, Eth1DataT any, ExecutionPayloadHeaderT any, ForkT any, ValidatorT any, ValidatorsT any, WithdrawalT any] struct { + *mock.Call +} + +// EVMInflationWithdrawal is a helper method to define mock.On call +func (_e *BeaconState_Expecter[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) EVMInflationWithdrawal() *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT] { + return &BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]{Call: _e.mock.On("EVMInflationWithdrawal")} +} + +func (_c *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) Run(run func()) *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT] { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) Return(_a0 WithdrawalT) *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT] { + _c.Call.Return(_a0) + return _c +} + +func (_c *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) RunAndReturn(run func() WithdrawalT) *BeaconState_EVMInflationWithdrawal_Call[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT] { + _c.Call.Return(run) + return _c +} + // ExpectedWithdrawals provides a mock function with given fields: func (_m *BeaconState[BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT, ForkT, ValidatorT, ValidatorsT, WithdrawalT]) ExpectedWithdrawals() ([]WithdrawalT, error) { ret := _m.Called() From 6382ef292cb149d893d6e0a7143ca381a6d7e841 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 00:12:23 +0100 Subject: [PATCH 36/53] Update mod/state-transition/pkg/core/state_processor_staking.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Cal Bera --- mod/state-transition/pkg/core/state_processor_staking.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 8009921725..7e79e1cbd4 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -226,8 +226,10 @@ func (sp *StateProcessor[ // processWithdrawals as per the Ethereum 2.0 specification. // https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-process_withdrawals // -// NOTE: This function is modified from the spec to allow a fixed withdrawal -// (must be the first withdrawal) used for EVM inflation. +// NOTE: Modified from the Ethereum 2.0 specification to support EVM inflation: +// 1. The first withdrawal MUST be a fixed EVM inflation withdrawal +// 2. Subsequent withdrawals (if any) are processed as validator withdrawals +// 3. This modification reduces the maximum validator withdrawals per block by one // //nolint:lll func (sp *StateProcessor[ From 56412abc0be1e88e29ccac3ffa2c36ea72cac91d Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 00:25:40 +0100 Subject: [PATCH 37/53] todo fix unit tests --- mod/state-transition/pkg/core/state/constants.go | 3 ++- mod/state-transition/pkg/core/state/statedb.go | 3 +-- mod/state-transition/pkg/core/state_processor_staking.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mod/state-transition/pkg/core/state/constants.go b/mod/state-transition/pkg/core/state/constants.go index 72adcd415d..a498daf681 100644 --- a/mod/state-transition/pkg/core/state/constants.go +++ b/mod/state-transition/pkg/core/state/constants.go @@ -34,7 +34,8 @@ const ( EVMInflationWithdrawalValidatorIndex = math.MaxUint64 ) -// Boonet special case for emergency minting of EVM tokens. +// Boonet special case for emergency minting of EVM tokens. TODO: remove with +// other special cases. const ( // EVMMintingSlot is the slot at which we force a single withdrawal to // mint EVMMintingAmount EVM tokens to EVMMintingAddress. No other diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 028ad52a00..95cc6661d2 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -190,7 +190,7 @@ func (s *StateDB[ // NOTE: This function is modified from the spec to allow a fixed withdrawal // (as the first withdrawal) used for EVM inflation. // -//nolint:lll +//nolint:lll,funlen,gocognit // TODO: Simplify when dropping special cases. func (s *StateDB[ _, _, _, _, _, _, ValidatorT, _, WithdrawalT, _, ]) ExpectedWithdrawals() ([]WithdrawalT, error) { @@ -215,7 +215,6 @@ func (s *StateDB[ if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { // Slot used to emergency mint EVM tokens. if slot.Unwrap() == EVMMintingSlot { - var withdrawal WithdrawalT withdrawals = append(withdrawals, withdrawal.New( 0, // NOT USED 0, // NOT USED diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 7e79e1cbd4..1d1ab3c3e2 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -229,9 +229,10 @@ func (sp *StateProcessor[ // NOTE: Modified from the Ethereum 2.0 specification to support EVM inflation: // 1. The first withdrawal MUST be a fixed EVM inflation withdrawal // 2. Subsequent withdrawals (if any) are processed as validator withdrawals -// 3. This modification reduces the maximum validator withdrawals per block by one +// 3. This modification reduces the maximum validator withdrawals per block by +// one // -//nolint:lll +//nolint:lll,funlen,gocognit // TODO: Simplify when dropping special cases. func (sp *StateProcessor[ BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, ]) processWithdrawals( From f9960d4f6c1e4acff30c344cd2bf7456c037adaf Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 00:28:48 +0100 Subject: [PATCH 38/53] fix unit --- .../pkg/core/state_processor_staking_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index 52daf4e321..9b2419d838 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -35,7 +35,7 @@ import ( ) func TestTransitionUpdateValidators(t *testing.T) { - cs := setupChain(t, components.BetnetChainSpecType) + cs := setupChain(t, components.BoonetChainSpecType) sp, st, ctx := setupState(t, cs) var ( @@ -129,7 +129,7 @@ func TestTransitionUpdateValidators(t *testing.T) { } func TestTransitionWithdrawals(t *testing.T) { - cs := setupChain(t, components.BetnetChainSpecType) + cs := setupChain(t, components.BoonetChainSpecType) sp, st, ctx := setupState(t, cs) var ( @@ -215,7 +215,7 @@ func TestTransitionWithdrawals(t *testing.T) { func TestTransitionMaxWithdrawals(t *testing.T) { // Use custom chain spec with max withdrawals set to 2. csData := spec.BaseSpec() - csData.DepositEth1ChainID = spec.BetnetEth1ChainID + csData.DepositEth1ChainID = spec.BoonetEth1ChainID csData.MaxWithdrawalsPerPayload = 2 cs, err := chain.NewChainSpec(csData) require.NoError(t, err) From e3fd55e76dbe3da77ea92ddfe08251e948187ba9 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 00:38:58 +0100 Subject: [PATCH 39/53] gen --- .../pkg/engine-primitives/mocks/blobs_bundle.mock.go | 2 +- .../engine-primitives/mocks/built_execution_payload_env.mock.go | 2 +- .../pkg/engine-primitives/mocks/payload_attributer.mock.go | 2 +- mod/geth-primitives/pkg/deposit/contract.abigen.go | 2 +- mod/node-api/backend/mocks/availability_store.mock.go | 2 +- mod/node-api/backend/mocks/beacon_block_header.mock.go | 2 +- mod/node-api/backend/mocks/beacon_state.mock.go | 2 +- mod/node-api/backend/mocks/block_store.mock.go | 2 +- mod/node-api/backend/mocks/deposit_store.mock.go | 2 +- mod/node-api/backend/mocks/node.mock.go | 2 +- mod/node-api/backend/mocks/state_processor.mock.go | 2 +- mod/node-api/backend/mocks/storage_backend.mock.go | 2 +- mod/node-api/backend/mocks/validator.mock.go | 2 +- mod/node-api/backend/mocks/withdrawal.mock.go | 2 +- mod/node-api/backend/mocks/withdrawal_credentials.mock.go | 2 +- mod/node-core/pkg/services/registry/mocks/basic.mock.go | 2 +- mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go | 2 +- .../pkg/services/registry/mocks/registry_option.mock.go | 2 +- mod/primitives/pkg/crypto/mocks/bls_signer.mock.go | 2 +- mod/state-transition/pkg/core/mocks/execution_engine.mock.go | 2 +- mod/storage/pkg/interfaces/mocks/db.mock.go | 2 +- mod/storage/pkg/pruner/mocks/beacon_block.mock.go | 2 +- mod/storage/pkg/pruner/mocks/block_event.mock.go | 2 +- mod/storage/pkg/pruner/mocks/prunable.mock.go | 2 +- mod/storage/pkg/pruner/mocks/pruner.mock.go | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go index a9755a8c7a..0f910642ff 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go index 2eb2e63c66..bb9afae800 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go index ce712b7f28..c6213b25c5 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/geth-primitives/pkg/deposit/contract.abigen.go b/mod/geth-primitives/pkg/deposit/contract.abigen.go index 5d121d9edf..dab3abd28c 100644 --- a/mod/geth-primitives/pkg/deposit/contract.abigen.go +++ b/mod/geth-primitives/pkg/deposit/contract.abigen.go @@ -32,7 +32,7 @@ var ( // BeaconDepositContractMetaData contains all meta data concerning the BeaconDepositContract contract. var BeaconDepositContractMetaData = &bind.MetaData{ ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"allowDeposit\",\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"number\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"cancelOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"completeOwnershipHandover\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"withdrawal_credentials\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositAuth\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositCount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"result\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ownershipHandoverExpiresAt\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"result\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"requestOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"event\",\"name\":\"Deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"credentials\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"index\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverCanceled\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverRequested\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"oldOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyInitialized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositNotMultipleOfGwei\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositValueTooHigh\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InsufficientDeposit\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidCredentialsLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidPubKeyLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidSignatureLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NewOwnerIsZeroAddress\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NoHandoverRequest\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"Unauthorized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnauthorizedDeposit\",\"inputs\":[]}]", - Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea26469706673582212209dfb8e5ead8b23553bd4102b9e66cae17b890a520a2c3b480698309f19d2819664736f6c634300081a0033", + Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea2646970667358221220b08e6fc3b9c94a2f65976bacf514e878deea80490a6ebe3959e6047117451a1464736f6c634300081a0033", } // BeaconDepositContractABI is the input ABI used to generate the binding from. diff --git a/mod/node-api/backend/mocks/availability_store.mock.go b/mod/node-api/backend/mocks/availability_store.mock.go index 26ab51f6ca..d26b082de6 100644 --- a/mod/node-api/backend/mocks/availability_store.mock.go +++ b/mod/node-api/backend/mocks/availability_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_block_header.mock.go b/mod/node-api/backend/mocks/beacon_block_header.mock.go index db5cfc4192..40f47d1bbb 100644 --- a/mod/node-api/backend/mocks/beacon_block_header.mock.go +++ b/mod/node-api/backend/mocks/beacon_block_header.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_state.mock.go b/mod/node-api/backend/mocks/beacon_state.mock.go index 99c0d2c4b9..3cc8edb930 100644 --- a/mod/node-api/backend/mocks/beacon_state.mock.go +++ b/mod/node-api/backend/mocks/beacon_state.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/block_store.mock.go b/mod/node-api/backend/mocks/block_store.mock.go index c5bc5b8467..0aec7824a8 100644 --- a/mod/node-api/backend/mocks/block_store.mock.go +++ b/mod/node-api/backend/mocks/block_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/deposit_store.mock.go b/mod/node-api/backend/mocks/deposit_store.mock.go index a226184c72..42efd34293 100644 --- a/mod/node-api/backend/mocks/deposit_store.mock.go +++ b/mod/node-api/backend/mocks/deposit_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/node.mock.go b/mod/node-api/backend/mocks/node.mock.go index 45a53055be..7b6ea6df8e 100644 --- a/mod/node-api/backend/mocks/node.mock.go +++ b/mod/node-api/backend/mocks/node.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/state_processor.mock.go b/mod/node-api/backend/mocks/state_processor.mock.go index 0314009602..90b28efe4d 100644 --- a/mod/node-api/backend/mocks/state_processor.mock.go +++ b/mod/node-api/backend/mocks/state_processor.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/storage_backend.mock.go b/mod/node-api/backend/mocks/storage_backend.mock.go index 2992bb6e90..8ddbf4eba0 100644 --- a/mod/node-api/backend/mocks/storage_backend.mock.go +++ b/mod/node-api/backend/mocks/storage_backend.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/validator.mock.go b/mod/node-api/backend/mocks/validator.mock.go index 997eae07ac..867842ed74 100644 --- a/mod/node-api/backend/mocks/validator.mock.go +++ b/mod/node-api/backend/mocks/validator.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal.mock.go b/mod/node-api/backend/mocks/withdrawal.mock.go index d0ef6cff94..d9bd959e99 100644 --- a/mod/node-api/backend/mocks/withdrawal.mock.go +++ b/mod/node-api/backend/mocks/withdrawal.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go index 6abab4521a..44769f067c 100644 --- a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go +++ b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/basic.mock.go b/mod/node-core/pkg/services/registry/mocks/basic.mock.go index c72558a571..2b75bf30e9 100644 --- a/mod/node-core/pkg/services/registry/mocks/basic.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/basic.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go index 13003c3117..b8c291669f 100644 --- a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go index d0239c9f3d..f5bd036c85 100644 --- a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go index fad1b08842..91a6942592 100644 --- a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go +++ b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go index 8bf5537e0c..6b65b7f9bf 100644 --- a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go +++ b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/interfaces/mocks/db.mock.go b/mod/storage/pkg/interfaces/mocks/db.mock.go index 956c2182d4..809d49ef3c 100644 --- a/mod/storage/pkg/interfaces/mocks/db.mock.go +++ b/mod/storage/pkg/interfaces/mocks/db.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go index 3f6fa20bc2..8d1dd864d2 100644 --- a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go +++ b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/block_event.mock.go b/mod/storage/pkg/pruner/mocks/block_event.mock.go index 0297db3ce3..0ef5bbc153 100644 --- a/mod/storage/pkg/pruner/mocks/block_event.mock.go +++ b/mod/storage/pkg/pruner/mocks/block_event.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/prunable.mock.go b/mod/storage/pkg/pruner/mocks/prunable.mock.go index 894d56ac32..056c3d36e9 100644 --- a/mod/storage/pkg/pruner/mocks/prunable.mock.go +++ b/mod/storage/pkg/pruner/mocks/prunable.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/pruner.mock.go b/mod/storage/pkg/pruner/mocks/pruner.mock.go index 6d5b0672c4..a167523f95 100644 --- a/mod/storage/pkg/pruner/mocks/pruner.mock.go +++ b/mod/storage/pkg/pruner/mocks/pruner.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.0. DO NOT EDIT. +// Code generated by mockery v2.49.1. DO NOT EDIT. package mocks From 22c86abf0b31e43259aba02eb2a92481859e4ab0 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 00:46:20 +0100 Subject: [PATCH 40/53] gen --- mod/geth-primitives/pkg/deposit/contract.abigen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/geth-primitives/pkg/deposit/contract.abigen.go b/mod/geth-primitives/pkg/deposit/contract.abigen.go index dab3abd28c..5d121d9edf 100644 --- a/mod/geth-primitives/pkg/deposit/contract.abigen.go +++ b/mod/geth-primitives/pkg/deposit/contract.abigen.go @@ -32,7 +32,7 @@ var ( // BeaconDepositContractMetaData contains all meta data concerning the BeaconDepositContract contract. var BeaconDepositContractMetaData = &bind.MetaData{ ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"allowDeposit\",\"inputs\":[{\"name\":\"depositor\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"number\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"cancelOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"completeOwnershipHandover\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"withdrawal_credentials\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositAuth\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositCount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"result\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ownershipHandoverExpiresAt\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"result\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"requestOwnershipHandover\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"event\",\"name\":\"Deposit\",\"inputs\":[{\"name\":\"pubkey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"credentials\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"index\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverCanceled\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipHandoverRequested\",\"inputs\":[{\"name\":\"pendingOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"oldOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyInitialized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositNotMultipleOfGwei\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"DepositValueTooHigh\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InsufficientDeposit\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidCredentialsLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidPubKeyLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidSignatureLength\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NewOwnerIsZeroAddress\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NoHandoverRequest\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"Unauthorized\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UnauthorizedDeposit\",\"inputs\":[]}]", - Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea2646970667358221220b08e6fc3b9c94a2f65976bacf514e878deea80490a6ebe3959e6047117451a1464736f6c634300081a0033", + Bin: "0x6080604052348015600e575f80fd5b50604051610c34380380610c34833981016040819052602b91608e565b6032816037565b5060b9565b638b78c6d819805415605057630dc149f05f526004601cfd5b6001600160a01b03909116801560ff1b8117909155805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b5f60208284031215609d575f80fd5b81516001600160a01b038116811460b2575f80fd5b9392505050565b610b6e806100c65f395ff3fe6080604052600436106100c3575f3560e01c80635b70fa2911610071578063f04e283e1161004c578063f04e283e14610207578063f2fde38b1461021a578063fee81cf41461022d575f80fd5b80635b70fa2914610199578063715018a6146101ac5780638da5cb5b146101b4575f80fd5b80633198a6b8116100a15780633198a6b81461013d57806354d1f13d146101725780635a7517ad1461017a575f80fd5b806301ffc9a7146100c757806325692962146100fb5780632dfdf0b514610105575b5f80fd5b3480156100d2575f80fd5b506100e66100e1366004610809565b61026c565b60405190151581526020015b60405180910390f35b610103610304565b005b348015610110575f80fd5b505f546101249067ffffffffffffffff1681565b60405167ffffffffffffffff90911681526020016100f2565b348015610148575f80fd5b50610124610157366004610877565b60016020525f908152604090205467ffffffffffffffff1681565b610103610351565b348015610185575f80fd5b506101036101943660046108a7565b61038a565b6101036101a736600461091d565b6103f0565b6101036104a5565b3480156101bf575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f2565b610103610215366004610877565b6104b8565b610103610228366004610877565b6104f5565b348015610238575f80fd5b5061025e610247366004610877565b63389a75e1600c9081525f91909152602090205490565b6040519081526020016100f2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b70fa2900000000000000000000000000000000000000000000000000000000145b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b61039261051b565b73ffffffffffffffffffffffffffffffffffffffff919091165f90815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff909216919091179055565b335f9081526001602052604081205467ffffffffffffffff169003610441576040517fce7ccd9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260016020526040812080549091906104679067ffffffffffffffff166109cd565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555061049c87878787878787610550565b50505050505050565b6104ad61051b565b6104b65f6106e0565b565b6104c061051b565b63389a75e1600c52805f526020600c2080544211156104e657636f5e88185f526004601cfd5b5f90556104f2816106e0565b50565b6104fd61051b565b8060601b61051257637448fbae5f526004601cfd5b6104f2816106e0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275433146104b6576382b429005f526004601cfd5b6030861461058a576040517f9f10647200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084146105c4576040517fb39bca1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081146105fe576040517f4be6321b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106088461074e565b905064077359400067ffffffffffffffff82161015610653576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000008116600167ffffffffffffffff928316908101909216179091556040517f68af751683498a9f9be59fe8b0d52a64dd155255d85cdb29fea30b1e3f891d46916106ce918b918b918b918b9188918b918b9190610a7a565b60405180910390a15050505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3811560ff1b8217905550565b5f61075d633b9aca0034610b12565b15610794576040517f40567b3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107a3633b9aca0034610b25565b905067ffffffffffffffff8111156107e7576040517f2aa6673400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6102fe5f345f385f3884865af16108055763b12d13eb5f526004601cfd5b5050565b5f60208284031215610819575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610848575f80fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610872575f80fd5b919050565b5f60208284031215610887575f80fd5b6108488261084f565b803567ffffffffffffffff81168114610872575f80fd5b5f80604083850312156108b8575f80fd5b6108c18361084f565b91506108cf60208401610890565b90509250929050565b5f8083601f8401126108e8575f80fd5b50813567ffffffffffffffff8111156108ff575f80fd5b602083019150836020828501011115610916575f80fd5b9250929050565b5f805f805f805f6080888a031215610933575f80fd5b873567ffffffffffffffff811115610949575f80fd5b6109558a828b016108d8565b909850965050602088013567ffffffffffffffff811115610974575f80fd5b6109808a828b016108d8565b9096509450610993905060408901610890565b9250606088013567ffffffffffffffff8111156109ae575f80fd5b6109ba8a828b016108d8565b989b979a50959850939692959293505050565b5f67ffffffffffffffff821680610a0b577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b60a081525f610a8d60a083018a8c610a33565b8281036020840152610aa081898b610a33565b905067ffffffffffffffff871660408401528281036060840152610ac5818688610a33565b91505067ffffffffffffffff831660808301529998505050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82610b2057610b20610ae5565b500690565b5f82610b3357610b33610ae5565b50049056fea26469706673582212209dfb8e5ead8b23553bd4102b9e66cae17b890a520a2c3b480698309f19d2819664736f6c634300081a0033", } // BeaconDepositContractABI is the input ABI used to generate the binding from. From 5bac0a18d24a5564008ad9b75179ebe5d3fb2752 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 10:51:24 +0100 Subject: [PATCH 41/53] special casing --- .../pkg/core/state/constants.go | 7 --- .../pkg/core/state/statedb.go | 32 ++++++------- .../pkg/core/state_processor_staking.go | 46 ++++++++++--------- 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/mod/state-transition/pkg/core/state/constants.go b/mod/state-transition/pkg/core/state/constants.go index 418c6c53d3..6d66433f6b 100644 --- a/mod/state-transition/pkg/core/state/constants.go +++ b/mod/state-transition/pkg/core/state/constants.go @@ -22,8 +22,6 @@ package state import ( "math" - - "github.com/berachain/beacon-kit/mod/config/pkg/spec" ) const ( @@ -41,11 +39,6 @@ const ( // Boonet special case for emergency minting of EVM tokens. TODO: remove with // other special cases. const ( - // EVMMintingSlot is the slot at which we force a single withdrawal to - // mint EVMMintingAmount EVM tokens to EVMMintingAddress. No other - // withdrawals are inserted at this slot. - EVMMintingSlot uint64 = spec.BoonetFork1Height - // EVMMintingAddress is the address at which we mint EVM tokens to. EVMMintingAddress = "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B" diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index 95cc6661d2..a697bee154 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -202,27 +202,27 @@ func (s *StateDB[ withdrawal WithdrawalT ) - if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { - // The first withdrawal is fixed to be the EVM inflation withdrawal. - withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) - } - slot, err := s.GetSlot() if err != nil { return nil, err } - if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { - // Slot used to emergency mint EVM tokens. - if slot.Unwrap() == EVMMintingSlot { - withdrawals = append(withdrawals, withdrawal.New( - 0, // NOT USED - 0, // NOT USED - common.NewExecutionAddressFromHex(EVMMintingAddress), - math.Gwei(EVMMintingAmount), - )) - return withdrawals, nil - } + if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot.Unwrap() == spec.BoonetFork1Height { + // Slot used to emergency mint EVM tokens on Boonet. + withdrawals = append(withdrawals, withdrawal.New( + 0, // NOT USED + 0, // NOT USED + common.NewExecutionAddressFromHex(EVMMintingAddress), + math.Gwei(EVMMintingAmount), + )) + return withdrawals, nil + } + + if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot.Unwrap() >= spec.BoonetFork2Height { + // The first withdrawal is fixed to be the EVM inflation withdrawal. + withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) } epoch := math.Epoch(slot.Unwrap() / s.cs.SlotsPerEpoch()) diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index d7c53d03f9..43b2799e67 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -29,7 +29,6 @@ import ( "github.com/berachain/beacon-kit/mod/primitives/pkg/common" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/mod/primitives/pkg/version" - "github.com/berachain/beacon-kit/mod/state-transition/pkg/core/state" "github.com/davecgh/go-spew/spew" ) @@ -197,6 +196,7 @@ func (sp *StateProcessor[ // Dequeue and verify the logs. var ( body = blk.GetBody() + slot = blk.GetSlot().Unwrap() nextValidatorIndex math.ValidatorIndex payload = body.GetExecutionPayload() payloadWithdrawals = payload.GetWithdrawals() @@ -208,7 +208,8 @@ func (sp *StateProcessor[ return err } numWithdrawals := len(expectedWithdrawals) - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot >= spec.BoonetFork2Height { // Enforce that there is at least one withdrawal for EVM inflation. if numWithdrawals == 0 { return ErrZeroWithdrawals @@ -224,22 +225,19 @@ func (sp *StateProcessor[ ) } - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { - // Slot used to emergency mint EVM tokens. - slot := blk.GetSlot() - if slot.Unwrap() == state.EVMMintingSlot { - // Sanity check. - wd := expectedWithdrawals[0] - if !wd.Equals(payloadWithdrawals[0]) { - return fmt.Errorf( - "minting withdrawal does not match expected %s, got %s", - spew.Sdump(wd), spew.Sdump(payloadWithdrawals[0]), - ) - } - - // No processing needed. - return nil + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot == spec.BoonetFork1Height { + // Slot used to emergency mint EVM tokens on Boonet. + if !expectedWithdrawals[0].Equals(payloadWithdrawals[0]) { + return fmt.Errorf( + "minting withdrawal does not match expected %s, got %s", + spew.Sdump(expectedWithdrawals[0]), + spew.Sdump(payloadWithdrawals[0]), + ) } + + // No processing needed. + return nil } // Compare and process each withdrawal. @@ -253,7 +251,8 @@ func (sp *StateProcessor[ ) } - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot >= spec.BoonetFork2Height { // The first withdrawal is the EVM inflation withdrawal. Aside from // simple validation, no processing to the state is needed. if i == 0 { @@ -272,7 +271,8 @@ func (sp *StateProcessor[ } } - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID { + if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot >= spec.BoonetFork2Height { // If there is only the EVM inflation withdrawal, no state update is // needed. if numWithdrawals == 1 { @@ -295,13 +295,15 @@ func (sp *StateProcessor[ // Update the next validator index to start the next withdrawal sweep. //#nosec:G701 // won't overflow in practice. if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { - // Next sweep starts after the latest withdrawal's validator index. - if sp.cs.DepositEth1ChainID() == spec.BartioChainID { - // For backwards compatibility with bArtio. + + if (sp.cs.DepositEth1ChainID() == spec.BartioChainID) || + (sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot < spec.BoonetFork2Height) { nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1) % math.ValidatorIndex(totalValidators) } else { + // Next sweep starts after the latest withdrawal's validator index. nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1]. GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) } From 3a85aa3147f7ded67cf36f0335f9110979929132 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 10:53:20 +0100 Subject: [PATCH 42/53] gen --- .../pkg/engine-primitives/mocks/blobs_bundle.mock.go | 2 +- .../engine-primitives/mocks/built_execution_payload_env.mock.go | 2 +- .../pkg/engine-primitives/mocks/payload_attributer.mock.go | 2 +- mod/node-api/backend/mocks/availability_store.mock.go | 2 +- mod/node-api/backend/mocks/beacon_block_header.mock.go | 2 +- mod/node-api/backend/mocks/beacon_state.mock.go | 2 +- mod/node-api/backend/mocks/block_store.mock.go | 2 +- mod/node-api/backend/mocks/deposit_store.mock.go | 2 +- mod/node-api/backend/mocks/node.mock.go | 2 +- mod/node-api/backend/mocks/state_processor.mock.go | 2 +- mod/node-api/backend/mocks/storage_backend.mock.go | 2 +- mod/node-api/backend/mocks/validator.mock.go | 2 +- mod/node-api/backend/mocks/withdrawal.mock.go | 2 +- mod/node-api/backend/mocks/withdrawal_credentials.mock.go | 2 +- mod/node-core/pkg/services/registry/mocks/basic.mock.go | 2 +- mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go | 2 +- .../pkg/services/registry/mocks/registry_option.mock.go | 2 +- mod/primitives/pkg/crypto/mocks/bls_signer.mock.go | 2 +- mod/state-transition/pkg/core/mocks/execution_engine.mock.go | 2 +- mod/state-transition/pkg/core/state_processor_staking.go | 1 - mod/storage/pkg/interfaces/mocks/db.mock.go | 2 +- mod/storage/pkg/pruner/mocks/beacon_block.mock.go | 2 +- mod/storage/pkg/pruner/mocks/block_event.mock.go | 2 +- mod/storage/pkg/pruner/mocks/prunable.mock.go | 2 +- mod/storage/pkg/pruner/mocks/pruner.mock.go | 2 +- 25 files changed, 24 insertions(+), 25 deletions(-) diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go index 0f910642ff..a9755a8c7a 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/blobs_bundle.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go index bb9afae800..2eb2e63c66 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/built_execution_payload_env.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go index c6213b25c5..ce712b7f28 100644 --- a/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go +++ b/mod/engine-primitives/pkg/engine-primitives/mocks/payload_attributer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/availability_store.mock.go b/mod/node-api/backend/mocks/availability_store.mock.go index d26b082de6..26ab51f6ca 100644 --- a/mod/node-api/backend/mocks/availability_store.mock.go +++ b/mod/node-api/backend/mocks/availability_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_block_header.mock.go b/mod/node-api/backend/mocks/beacon_block_header.mock.go index 40f47d1bbb..db5cfc4192 100644 --- a/mod/node-api/backend/mocks/beacon_block_header.mock.go +++ b/mod/node-api/backend/mocks/beacon_block_header.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/beacon_state.mock.go b/mod/node-api/backend/mocks/beacon_state.mock.go index 3cc8edb930..99c0d2c4b9 100644 --- a/mod/node-api/backend/mocks/beacon_state.mock.go +++ b/mod/node-api/backend/mocks/beacon_state.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/block_store.mock.go b/mod/node-api/backend/mocks/block_store.mock.go index 0aec7824a8..c5bc5b8467 100644 --- a/mod/node-api/backend/mocks/block_store.mock.go +++ b/mod/node-api/backend/mocks/block_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/deposit_store.mock.go b/mod/node-api/backend/mocks/deposit_store.mock.go index 42efd34293..a226184c72 100644 --- a/mod/node-api/backend/mocks/deposit_store.mock.go +++ b/mod/node-api/backend/mocks/deposit_store.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/node.mock.go b/mod/node-api/backend/mocks/node.mock.go index 7b6ea6df8e..45a53055be 100644 --- a/mod/node-api/backend/mocks/node.mock.go +++ b/mod/node-api/backend/mocks/node.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/state_processor.mock.go b/mod/node-api/backend/mocks/state_processor.mock.go index 90b28efe4d..0314009602 100644 --- a/mod/node-api/backend/mocks/state_processor.mock.go +++ b/mod/node-api/backend/mocks/state_processor.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/storage_backend.mock.go b/mod/node-api/backend/mocks/storage_backend.mock.go index 8ddbf4eba0..2992bb6e90 100644 --- a/mod/node-api/backend/mocks/storage_backend.mock.go +++ b/mod/node-api/backend/mocks/storage_backend.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/validator.mock.go b/mod/node-api/backend/mocks/validator.mock.go index 867842ed74..997eae07ac 100644 --- a/mod/node-api/backend/mocks/validator.mock.go +++ b/mod/node-api/backend/mocks/validator.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal.mock.go b/mod/node-api/backend/mocks/withdrawal.mock.go index d9bd959e99..d0ef6cff94 100644 --- a/mod/node-api/backend/mocks/withdrawal.mock.go +++ b/mod/node-api/backend/mocks/withdrawal.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go index 44769f067c..6abab4521a 100644 --- a/mod/node-api/backend/mocks/withdrawal_credentials.mock.go +++ b/mod/node-api/backend/mocks/withdrawal_credentials.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/basic.mock.go b/mod/node-core/pkg/services/registry/mocks/basic.mock.go index 2b75bf30e9..c72558a571 100644 --- a/mod/node-core/pkg/services/registry/mocks/basic.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/basic.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go index b8c291669f..13003c3117 100644 --- a/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/dispatcher.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go index f5bd036c85..d0239c9f3d 100644 --- a/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go +++ b/mod/node-core/pkg/services/registry/mocks/registry_option.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go index 91a6942592..fad1b08842 100644 --- a/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go +++ b/mod/primitives/pkg/crypto/mocks/bls_signer.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go index 6b65b7f9bf..8bf5537e0c 100644 --- a/mod/state-transition/pkg/core/mocks/execution_engine.mock.go +++ b/mod/state-transition/pkg/core/mocks/execution_engine.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 43b2799e67..8ca7990e8b 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -295,7 +295,6 @@ func (sp *StateProcessor[ // Update the next validator index to start the next withdrawal sweep. //#nosec:G701 // won't overflow in practice. if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { - if (sp.cs.DepositEth1ChainID() == spec.BartioChainID) || (sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && slot < spec.BoonetFork2Height) { diff --git a/mod/storage/pkg/interfaces/mocks/db.mock.go b/mod/storage/pkg/interfaces/mocks/db.mock.go index 809d49ef3c..956c2182d4 100644 --- a/mod/storage/pkg/interfaces/mocks/db.mock.go +++ b/mod/storage/pkg/interfaces/mocks/db.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go index 8d1dd864d2..3f6fa20bc2 100644 --- a/mod/storage/pkg/pruner/mocks/beacon_block.mock.go +++ b/mod/storage/pkg/pruner/mocks/beacon_block.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/block_event.mock.go b/mod/storage/pkg/pruner/mocks/block_event.mock.go index 0ef5bbc153..0297db3ce3 100644 --- a/mod/storage/pkg/pruner/mocks/block_event.mock.go +++ b/mod/storage/pkg/pruner/mocks/block_event.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/prunable.mock.go b/mod/storage/pkg/pruner/mocks/prunable.mock.go index 056c3d36e9..894d56ac32 100644 --- a/mod/storage/pkg/pruner/mocks/prunable.mock.go +++ b/mod/storage/pkg/pruner/mocks/prunable.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks diff --git a/mod/storage/pkg/pruner/mocks/pruner.mock.go b/mod/storage/pkg/pruner/mocks/pruner.mock.go index a167523f95..6d5b0672c4 100644 --- a/mod/storage/pkg/pruner/mocks/pruner.mock.go +++ b/mod/storage/pkg/pruner/mocks/pruner.mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.49.1. DO NOT EDIT. +// Code generated by mockery v2.49.0. DO NOT EDIT. package mocks From cbfc21849dd09dda3e3e7c7bed7767b42c392d7e Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 10:56:23 +0100 Subject: [PATCH 43/53] nit --- mod/chain-spec/pkg/chain/chain_spec.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index 828afae9f4..d5c2323f5e 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -237,6 +237,8 @@ func (c *chainSpec[ return ErrInsufficientMaxWithdrawalsPerPayload } + // The values can be zero or non-zero, n + // TODO: Add more validation rules here. return nil } From 7f3e9fc98271f833f062a6f34c3078c483d5f9db Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 14:16:37 +0100 Subject: [PATCH 44/53] temp --- mod/chain-spec/pkg/chain/chain_spec.go | 2 +- mod/config/pkg/spec/special_cases.go | 8 +++---- mod/state-transition/pkg/core/core_test.go | 21 +++++++++++++++++++ .../pkg/core/state_processor.go | 2 ++ .../pkg/core/state_processor_genesis.go | 3 +++ .../pkg/core/state_processor_staking_test.go | 15 +++++++++++++ 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index d5c2323f5e..7aa3da1c1c 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -237,7 +237,7 @@ func (c *chainSpec[ return ErrInsufficientMaxWithdrawalsPerPayload } - // The values can be zero or non-zero, n + // EVM Inflation values can be zero or non-zero, no validation needed. // TODO: Add more validation rules here. return nil diff --git a/mod/config/pkg/spec/special_cases.go b/mod/config/pkg/spec/special_cases.go index b21549f9c4..36a55f1d17 100644 --- a/mod/config/pkg/spec/special_cases.go +++ b/mod/config/pkg/spec/special_cases.go @@ -20,8 +20,6 @@ package spec -import "math" - // Special cased Bartio for some ad-hoc handling due to the way // some bugs were handled on Bartio. To be removed. const ( @@ -31,8 +29,10 @@ const ( BArtioValRoot = "0x9147586693b6e8faa837715c0f3071c2000045b54233901c2e7871b15872bc43" ) -const ( // Planned hard-fork upgrades on boonet. +// Planned hard-fork upgrades on boonet. +const ( BoonetFork1Height uint64 = 69420 - BoonetFork2Height uint64 = math.MaxUint64 + // TODO: modify this to be the actual fork height. Avoid overflow. + BoonetFork2Height uint64 = 99999999999999 ) diff --git a/mod/state-transition/pkg/core/core_test.go b/mod/state-transition/pkg/core/core_test.go index 4828fc24a3..f71bd4ddcf 100644 --- a/mod/state-transition/pkg/core/core_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -254,6 +254,27 @@ func setupState( return sp, beaconState, depositStore, ctx } +func progressStateToSlot( + t *testing.T, + beaconState *TestBeaconStateT, + slot math.U64, +) { + t.Helper() + + if slot == math.U64(0) { + t.Fatal("for genesis slot, use InitializePreminedBeaconStateFromEth1") + } + + beaconState.SetSlot(slot) + beaconState.SetLatestBlockHeader(types.NewBeaconBlockHeader( + slot, + math.U64(0), + common.Root{}, + common.Root{}, + common.Root{}, + )) +} + func buildNextBlock( t *testing.T, beaconState *TestBeaconStateT, diff --git a/mod/state-transition/pkg/core/state_processor.go b/mod/state-transition/pkg/core/state_processor.go index e82697f427..777bd2f472 100644 --- a/mod/state-transition/pkg/core/state_processor.go +++ b/mod/state-transition/pkg/core/state_processor.go @@ -196,6 +196,8 @@ func (sp *StateProcessor[ return nil, err } + fmt.Println("val0", *validatorUpdates[0], "val1", *validatorUpdates[1]) + return validatorUpdates, nil } diff --git a/mod/state-transition/pkg/core/state_processor_genesis.go b/mod/state-transition/pkg/core/state_processor_genesis.go index 77947bc23c..308672f3cf 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis.go +++ b/mod/state-transition/pkg/core/state_processor_genesis.go @@ -103,6 +103,9 @@ func (sp *StateProcessor[ return nil, err } } + // if err := st.SetEth1DepositIndex(uint64(len(deposits))); err != nil { + // return nil, err + // } // TODO: process activations. validators, err := st.GetValidators() diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index b5cfe44c7f..b3ea4438bb 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -73,6 +73,15 @@ func TestTransitionUpdateValidators(t *testing.T) { ) require.NoError(t, err) + // Progress state to fork 2. + // progressStateToSlot(t, st, math.U64(spec.BoonetFork2Height)) + // _, err = sp.ProcessSlots(st, math.U64(spec.BoonetFork2Height)) + // require.NoError(t, err) + // blkHeader, err := st.GetLatestBlockHeader() + // require.NoError(t, err) + // blkHeader.SetSlot(math.U64(spec.BoonetFork2Height) - 1) + // require.NoError(t, st.SetLatestBlockHeader(blkHeader)) + // create test inputs blkDeposits := []*types.Deposit{ { @@ -171,6 +180,9 @@ func TestTransitionWithdrawals(t *testing.T) { ) require.NoError(t, err) + // Progress state to fork 2. + progressStateToSlot(t, st, math.U64(spec.BoonetFork2Height)) + // Assert validator 1 balance before withdrawal. val1Bal, err := st.GetBalance(math.U64(1)) require.NoError(t, err) @@ -260,6 +272,9 @@ func TestTransitionMaxWithdrawals(t *testing.T) { ) require.NoError(t, err) + // Progress state to fork 2. + progressStateToSlot(t, st, math.U64(spec.BoonetFork2Height)) + // Assert validator balances before withdrawal. val0Bal, err := st.GetBalance(math.U64(0)) require.NoError(t, err) From bb9ab6e4bb1977a1c3afd4c12388bfbbd85e01c4 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 14:18:11 +0100 Subject: [PATCH 45/53] fix --- mod/state-transition/pkg/core/core_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod/state-transition/pkg/core/core_test.go b/mod/state-transition/pkg/core/core_test.go index f71bd4ddcf..e72dd71798 100644 --- a/mod/state-transition/pkg/core/core_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -35,6 +35,7 @@ import ( engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives" "github.com/berachain/beacon-kit/mod/log/pkg/noop" "github.com/berachain/beacon-kit/mod/node-core/pkg/components" + nodemetrics "github.com/berachain/beacon-kit/mod/node-core/pkg/components/metrics" "github.com/berachain/beacon-kit/mod/primitives/pkg/bytes" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" cryptomocks "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto/mocks" @@ -243,6 +244,7 @@ func setupState( func(bytes.B48) ([]byte, error) { return dummyProposerAddr, nil }, + nodemetrics.NewNoOpTelemetrySink(), ) ctx := &transition.Context{ From f00cb29957386012ea7d46d348c9173761484821 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 14:35:14 +0100 Subject: [PATCH 46/53] fix test --- .../pkg/core/state_processor.go | 2 -- .../pkg/core/state_processor_staking.go | 10 ++++--- .../pkg/core/state_processor_staking_test.go | 28 +++++-------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor.go b/mod/state-transition/pkg/core/state_processor.go index f3ef469878..4c04fd89e2 100644 --- a/mod/state-transition/pkg/core/state_processor.go +++ b/mod/state-transition/pkg/core/state_processor.go @@ -200,8 +200,6 @@ func (sp *StateProcessor[ return nil, err } - fmt.Println("val0", *validatorUpdates[0], "val1", *validatorUpdates[1]) - return validatorUpdates, nil } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 8ca7990e8b..44e599e91f 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -281,10 +281,12 @@ func (sp *StateProcessor[ } // Next sweep starts after the latest withdrawal's validator index. - if err = st.SetNextWithdrawalIndex( - (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), - ); err != nil { - return err + if numWithdrawals != 0 { + if err = st.SetNextWithdrawalIndex( + (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), + ); err != nil { + return err + } } totalValidators, err := st.GetTotalValidators() diff --git a/mod/state-transition/pkg/core/state_processor_staking_test.go b/mod/state-transition/pkg/core/state_processor_staking_test.go index b3ea4438bb..fe52d2c473 100644 --- a/mod/state-transition/pkg/core/state_processor_staking_test.go +++ b/mod/state-transition/pkg/core/state_processor_staking_test.go @@ -73,15 +73,6 @@ func TestTransitionUpdateValidators(t *testing.T) { ) require.NoError(t, err) - // Progress state to fork 2. - // progressStateToSlot(t, st, math.U64(spec.BoonetFork2Height)) - // _, err = sp.ProcessSlots(st, math.U64(spec.BoonetFork2Height)) - // require.NoError(t, err) - // blkHeader, err := st.GetLatestBlockHeader() - // require.NoError(t, err) - // blkHeader.SetSlot(math.U64(spec.BoonetFork2Height) - 1) - // require.NoError(t, st.SetLatestBlockHeader(blkHeader)) - // create test inputs blkDeposits := []*types.Deposit{ { @@ -96,13 +87,10 @@ func TestTransitionUpdateValidators(t *testing.T) { st, &types.BeaconBlockBody{ ExecutionPayload: &types.ExecutionPayload{ - Timestamp: 10, - ExtraData: []byte("testing"), - Transactions: [][]byte{}, - Withdrawals: []*engineprimitives.Withdrawal{ - // The first withdrawal is always for EVM inflation. - st.EVMInflationWithdrawal(), - }, + Timestamp: 10, + ExtraData: []byte("testing"), + Transactions: [][]byte{}, + Withdrawals: []*engineprimitives.Withdrawal{}, BaseFeePerGas: math.NewU256(0), }, Eth1Data: &types.Eth1Data{}, @@ -216,12 +204,11 @@ func TestTransitionWithdrawals(t *testing.T) { ) // Run the test. - vals, err := sp.Transition(ctx, st, blk) + _, err = sp.Transition(ctx, st, blk) // Check outputs and ensure withdrawals in payload is consistent with // statedb expected withdrawals. require.NoError(t, err) - require.Zero(t, vals) // Assert validator 1 balance after withdrawal. val1BalAfter, err := st.GetBalance(math.U64(1)) @@ -312,12 +299,11 @@ func TestTransitionMaxWithdrawals(t *testing.T) { ) // Run the test. - vals, err := sp.Transition(ctx, st, blk) + _, err = sp.Transition(ctx, st, blk) // Check outputs and ensure withdrawals in payload is consistent with // statedb expected withdrawals. require.NoError(t, err) - require.Zero(t, vals) // Assert validator balances after withdrawal, ensuring only validator 0 is // withdrawn from. @@ -359,7 +345,7 @@ func TestTransitionMaxWithdrawals(t *testing.T) { ) // Run the test. - vals, err = sp.Transition(ctx, st, blk) + vals, err := sp.Transition(ctx, st, blk) // Check outputs and ensure withdrawals in payload is consistent with // statedb expected withdrawals. From 97faad58c328d578505384cee867b269184500d2 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 14:43:25 +0100 Subject: [PATCH 47/53] lint --- mod/state-transition/pkg/core/core_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/state-transition/pkg/core/core_test.go b/mod/state-transition/pkg/core/core_test.go index e72dd71798..e4366ceca0 100644 --- a/mod/state-transition/pkg/core/core_test.go +++ b/mod/state-transition/pkg/core/core_test.go @@ -267,14 +267,16 @@ func progressStateToSlot( t.Fatal("for genesis slot, use InitializePreminedBeaconStateFromEth1") } - beaconState.SetSlot(slot) - beaconState.SetLatestBlockHeader(types.NewBeaconBlockHeader( + err := beaconState.SetSlot(slot) + require.NoError(t, err) + err = beaconState.SetLatestBlockHeader(types.NewBeaconBlockHeader( slot, math.U64(0), common.Root{}, common.Root{}, common.Root{}, )) + require.NoError(t, err) } func buildNextBlock( From 12996e5fe6abb5ad0f1ae007e3e3136214ae4b67 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 15:43:15 +0100 Subject: [PATCH 48/53] remove unused --- mod/state-transition/pkg/core/state_processor_genesis.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_genesis.go b/mod/state-transition/pkg/core/state_processor_genesis.go index 308672f3cf..77947bc23c 100644 --- a/mod/state-transition/pkg/core/state_processor_genesis.go +++ b/mod/state-transition/pkg/core/state_processor_genesis.go @@ -103,9 +103,6 @@ func (sp *StateProcessor[ return nil, err } } - // if err := st.SetEth1DepositIndex(uint64(len(deposits))); err != nil { - // return nil, err - // } // TODO: process activations. validators, err := st.GetValidators() From 444a2fa559e1b3f896c56e879b706a8327664559 Mon Sep 17 00:00:00 2001 From: Alberto Benegiamo Date: Thu, 28 Nov 2024 01:26:28 +0100 Subject: [PATCH 49/53] fork cleanup for withdrawals (#2187) Co-authored-by: Cal Bera --- .../pkg/core/state/statedb.go | 20 +- .../pkg/core/state_processor_staking.go | 150 ---------- .../pkg/core/state_processor_withdrawals.go | 267 ++++++++++++++++++ ...s_validation.go => validation_deposits.go} | 0 4 files changed, 281 insertions(+), 156 deletions(-) create mode 100644 mod/state-transition/pkg/core/state_processor_withdrawals.go rename mod/state-transition/pkg/core/{deposits_validation.go => validation_deposits.go} (100%) diff --git a/mod/state-transition/pkg/core/state/statedb.go b/mod/state-transition/pkg/core/state/statedb.go index a697bee154..8a2d925fa3 100644 --- a/mod/state-transition/pkg/core/state/statedb.go +++ b/mod/state-transition/pkg/core/state/statedb.go @@ -190,7 +190,7 @@ func (s *StateDB[ // NOTE: This function is modified from the spec to allow a fixed withdrawal // (as the first withdrawal) used for EVM inflation. // -//nolint:lll,funlen,gocognit // TODO: Simplify when dropping special cases. +//nolint:lll,funlen // TODO: Simplify when dropping special cases. func (s *StateDB[ _, _, _, _, _, _, ValidatorT, _, WithdrawalT, _, ]) ExpectedWithdrawals() ([]WithdrawalT, error) { @@ -207,8 +207,13 @@ func (s *StateDB[ return nil, err } - if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot.Unwrap() == spec.BoonetFork1Height { + // Handle special cases wherever it's necessary + switch { + case s.cs.DepositEth1ChainID() == spec.BartioChainID: + // nothing special to do + + case s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot == math.U64(spec.BoonetFork1Height): // Slot used to emergency mint EVM tokens on Boonet. withdrawals = append(withdrawals, withdrawal.New( 0, // NOT USED @@ -217,10 +222,13 @@ func (s *StateDB[ math.Gwei(EVMMintingAmount), )) return withdrawals, nil - } - if s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot.Unwrap() >= spec.BoonetFork2Height { + case s.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot < math.U64(spec.BoonetFork2Height): + // Boonet inherited the Bartio behaviour pre BoonetFork2Height + // nothing specific to do + + default: // The first withdrawal is fixed to be the EVM inflation withdrawal. withdrawals = append(withdrawals, s.EVMInflationWithdrawal()) } diff --git a/mod/state-transition/pkg/core/state_processor_staking.go b/mod/state-transition/pkg/core/state_processor_staking.go index 44e599e91f..1d5831673c 100644 --- a/mod/state-transition/pkg/core/state_processor_staking.go +++ b/mod/state-transition/pkg/core/state_processor_staking.go @@ -21,15 +21,11 @@ package core import ( - "fmt" - "github.com/berachain/beacon-kit/mod/config/pkg/spec" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" - "github.com/berachain/beacon-kit/mod/errors" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/mod/primitives/pkg/version" - "github.com/davecgh/go-spew/spew" ) // processOperations processes the operations and ensures they match the @@ -176,149 +172,3 @@ func (sp *StateProcessor[ } return st.IncreaseBalance(idx, dep.GetAmount()) } - -// processWithdrawals as per the Ethereum 2.0 specification. -// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-process_withdrawals -// -// NOTE: Modified from the Ethereum 2.0 specification to support EVM inflation: -// 1. The first withdrawal MUST be a fixed EVM inflation withdrawal -// 2. Subsequent withdrawals (if any) are processed as validator withdrawals -// 3. This modification reduces the maximum validator withdrawals per block by -// one -// -//nolint:lll,funlen,gocognit // TODO: Simplify when dropping special cases. -func (sp *StateProcessor[ - BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, -]) processWithdrawals( - st BeaconStateT, - blk BeaconBlockT, -) error { - // Dequeue and verify the logs. - var ( - body = blk.GetBody() - slot = blk.GetSlot().Unwrap() - nextValidatorIndex math.ValidatorIndex - payload = body.GetExecutionPayload() - payloadWithdrawals = payload.GetWithdrawals() - ) - - // Get the expected withdrawals. - expectedWithdrawals, err := st.ExpectedWithdrawals() - if err != nil { - return err - } - numWithdrawals := len(expectedWithdrawals) - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot >= spec.BoonetFork2Height { - // Enforce that there is at least one withdrawal for EVM inflation. - if numWithdrawals == 0 { - return ErrZeroWithdrawals - } - } - - // Ensure the expected and payload withdrawals have the same length. - if numWithdrawals != len(payloadWithdrawals) { - return errors.Wrapf( - ErrNumWithdrawalsMismatch, - "withdrawals do not match expected length %d, got %d", - numWithdrawals, len(payloadWithdrawals), - ) - } - - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot == spec.BoonetFork1Height { - // Slot used to emergency mint EVM tokens on Boonet. - if !expectedWithdrawals[0].Equals(payloadWithdrawals[0]) { - return fmt.Errorf( - "minting withdrawal does not match expected %s, got %s", - spew.Sdump(expectedWithdrawals[0]), - spew.Sdump(payloadWithdrawals[0]), - ) - } - - // No processing needed. - return nil - } - - // Compare and process each withdrawal. - for i, wd := range expectedWithdrawals { - // Ensure the withdrawals match the local state. - if !wd.Equals(payloadWithdrawals[i]) { - return errors.Wrapf( - ErrWithdrawalMismatch, - "withdrawal at index %d does not match expected %s, got %s", - i, spew.Sdump(wd), spew.Sdump(payloadWithdrawals[i]), - ) - } - - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot >= spec.BoonetFork2Height { - // The first withdrawal is the EVM inflation withdrawal. Aside from - // simple validation, no processing to the state is needed. - if i == 0 { - if !wd.Equals(st.EVMInflationWithdrawal()) { - return ErrFirstWithdrawalNotEVMInflation - } - continue - } - } - - // Process the validator withdrawal. - if err = st.DecreaseBalance( - wd.GetValidatorIndex(), wd.GetAmount(), - ); err != nil { - return err - } - } - - if sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot >= spec.BoonetFork2Height { - // If there is only the EVM inflation withdrawal, no state update is - // needed. - if numWithdrawals == 1 { - return nil - } - } - - // Next sweep starts after the latest withdrawal's validator index. - if numWithdrawals != 0 { - if err = st.SetNextWithdrawalIndex( - (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), - ); err != nil { - return err - } - } - - totalValidators, err := st.GetTotalValidators() - if err != nil { - return err - } - - // Update the next validator index to start the next withdrawal sweep. - //#nosec:G701 // won't overflow in practice. - if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { - if (sp.cs.DepositEth1ChainID() == spec.BartioChainID) || - (sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && - slot < spec.BoonetFork2Height) { - nextValidatorIndex = - (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1) % - math.ValidatorIndex(totalValidators) - } else { - // Next sweep starts after the latest withdrawal's validator index. - nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1]. - GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) - } - } else { - // Advance sweep by the max length of the sweep if there was not a full - // set of withdrawals. - nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() - if err != nil { - return err - } - nextValidatorIndex += math.ValidatorIndex( - sp.cs.MaxValidatorsPerWithdrawalsSweep()) - nextValidatorIndex %= math.ValidatorIndex(totalValidators) - } - - return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) -} diff --git a/mod/state-transition/pkg/core/state_processor_withdrawals.go b/mod/state-transition/pkg/core/state_processor_withdrawals.go new file mode 100644 index 0000000000..d9f80870c6 --- /dev/null +++ b/mod/state-transition/pkg/core/state_processor_withdrawals.go @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package core + +import ( + "fmt" + + "github.com/berachain/beacon-kit/mod/config/pkg/spec" + "github.com/berachain/beacon-kit/mod/errors" + "github.com/berachain/beacon-kit/mod/primitives/pkg/math" + "github.com/davecgh/go-spew/spew" +) + +// processWithdrawals as per the Ethereum 2.0 specification. +// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-process_withdrawals +// +// NOTE: Modified from the Ethereum 2.0 specification to support EVM inflation: +// 1. The first withdrawal MUST be a fixed EVM inflation withdrawal +// 2. Subsequent withdrawals (if any) are processed as validator withdrawals +// 3. This modification reduces the maximum validator withdrawals per block by +// one +// +//nolint:lll // TODO: Simplify when dropping special cases. +func (sp *StateProcessor[ + BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, +]) processWithdrawals( + st BeaconStateT, + blk BeaconBlockT, +) error { + // Dequeue and verify the logs. + var ( + body = blk.GetBody() + payload = body.GetExecutionPayload() + payloadWithdrawals = payload.GetWithdrawals() + ) + + // Get the expected withdrawals. + expectedWithdrawals, err := st.ExpectedWithdrawals() + if err != nil { + return err + } + + return sp.processWithdrawalsByFork( + st, expectedWithdrawals, payloadWithdrawals) +} + +func (sp *StateProcessor[ + _, _, _, BeaconStateT, _, _, _, _, _, _, + _, _, _, _, WithdrawalT, WithdrawalsT, _, +]) processWithdrawalsByFork( + st BeaconStateT, + expectedWithdrawals []WithdrawalT, + payloadWithdrawals []WithdrawalT, +) error { + slot, err := st.GetSlot() + if err != nil { + return fmt.Errorf( + "failed loading slot while processing deposits: %w", err, + ) + } + + // Common validations + if len(expectedWithdrawals) != len(payloadWithdrawals) { + return errors.Wrapf( + ErrNumWithdrawalsMismatch, + "withdrawals do not match expected length %d, got %d", + len(expectedWithdrawals), len(payloadWithdrawals), + ) + } + + // Chain/Fork specific processing + switch { + case sp.cs.DepositEth1ChainID() == spec.BartioChainID: + return sp.processWithdrawalsBartio( + st, + expectedWithdrawals, + payloadWithdrawals, + ) + + case sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot == math.U64(spec.BoonetFork1Height): + // Slot used to emergency mint EVM tokens on Boonet. + if !expectedWithdrawals[0].Equals(payloadWithdrawals[0]) { + return fmt.Errorf( + "minting withdrawal does not match expected %s, got %s", + spew.Sdump(expectedWithdrawals[0]), + spew.Sdump(payloadWithdrawals[0]), + ) + } + + return nil // No processing needed. + + case sp.cs.DepositEth1ChainID() == spec.BoonetEth1ChainID && + slot < math.U64(spec.BoonetFork2Height): + // Boonet inherited the Bartio behaviour pre BoonetFork2Height + // nothing specific to do + return sp.processWithdrawalsBartio( + st, + expectedWithdrawals, + payloadWithdrawals, + ) + + default: + return sp.processWithdrawalsDefault( + st, + expectedWithdrawals, + payloadWithdrawals, + ) + } +} + +func (sp *StateProcessor[ + _, _, _, BeaconStateT, _, _, _, _, _, _, + _, _, _, _, WithdrawalT, WithdrawalsT, _, +]) processWithdrawalsBartio( + st BeaconStateT, + expectedWithdrawals []WithdrawalT, + payloadWithdrawals []WithdrawalT, +) error { + for i, wd := range expectedWithdrawals { + // Ensure the withdrawals match the local state. + if !wd.Equals(payloadWithdrawals[i]) { + return errors.Wrapf( + ErrWithdrawalMismatch, + "withdrawal at index %d does not match expected %s, got %s", + i, spew.Sdump(wd), spew.Sdump(payloadWithdrawals[i]), + ) + } + + // Process the validator withdrawal. + if err := st.DecreaseBalance( + wd.GetValidatorIndex(), wd.GetAmount(), + ); err != nil { + return err + } + } + + if len(expectedWithdrawals) != 0 { + if err := st.SetNextWithdrawalIndex( + (expectedWithdrawals[len(expectedWithdrawals)-1]. + GetIndex() + 1).Unwrap(), + ); err != nil { + return err + } + } + + totalValidators, err := st.GetTotalValidators() + if err != nil { + return err + } + + // Update the next validator index to start the next withdrawal sweep. + var nextValidatorIndex math.ValidatorIndex + + //#nosec:G701 // won't overflow in practice. + if len(expectedWithdrawals) == int(sp.cs.MaxWithdrawalsPerPayload()) { + nextValidatorIndex = + (expectedWithdrawals[len(expectedWithdrawals)-1].GetIndex() + 1) % + math.ValidatorIndex(totalValidators) + // Note: this is a bug, we should have used ValidatorIndex instead of + // GetIndex. processWithdrawalsDefault fixes it + } else { + // Advance sweep by the max length of the sweep if there was not a full + // set of withdrawals. + nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() + if err != nil { + return err + } + nextValidatorIndex += math.ValidatorIndex( + sp.cs.MaxValidatorsPerWithdrawalsSweep()) + nextValidatorIndex %= math.ValidatorIndex(totalValidators) + } + + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) +} + +func (sp *StateProcessor[ + _, _, _, BeaconStateT, _, _, _, _, _, _, + _, _, _, _, WithdrawalT, WithdrawalsT, _, +]) processWithdrawalsDefault( + st BeaconStateT, + expectedWithdrawals []WithdrawalT, + payloadWithdrawals []WithdrawalT, +) error { + // Enforce that first withdrawal is EVM inflation + if len(payloadWithdrawals) == 0 { + return ErrZeroWithdrawals + } + if !payloadWithdrawals[0].Equals(st.EVMInflationWithdrawal()) { + return ErrFirstWithdrawalNotEVMInflation + } + numWithdrawals := len(expectedWithdrawals) + + // Process all subsequent validator withdrawals. + for i := 1; i < numWithdrawals; i++ { + // Ensure the withdrawals match the local state. + if !expectedWithdrawals[i].Equals(payloadWithdrawals[i]) { + return errors.Wrapf( + ErrWithdrawalMismatch, + "withdrawal at index %d does not match expected %s, got %s", + i, + spew.Sdump(expectedWithdrawals[i]), + spew.Sdump(payloadWithdrawals[i]), + ) + } + + if err := st.DecreaseBalance( + expectedWithdrawals[i].GetValidatorIndex(), + expectedWithdrawals[i].GetAmount(), + ); err != nil { + return err + } + } + + if numWithdrawals > 1 { + if err := st.SetNextWithdrawalIndex( + (expectedWithdrawals[numWithdrawals-1].GetIndex() + 1).Unwrap(), + ); err != nil { + return err + } + } + + totalValidators, err := st.GetTotalValidators() + if err != nil { + return err + } + + // Update the next validator index to start the next withdrawal sweep. + var nextValidatorIndex math.ValidatorIndex + + //#nosec:G701 // won't overflow in practice. + if numWithdrawals == int(sp.cs.MaxWithdrawalsPerPayload()) { + // Next sweep starts after the latest withdrawal's validator index. + nextValidatorIndex = (expectedWithdrawals[numWithdrawals-1]. + GetValidatorIndex() + 1) % math.ValidatorIndex(totalValidators) + } else { + // Advance sweep by the max length of the sweep if there was not a full + // set of withdrawals. + nextValidatorIndex, err = st.GetNextWithdrawalValidatorIndex() + if err != nil { + return err + } + nextValidatorIndex += math.ValidatorIndex( + sp.cs.MaxValidatorsPerWithdrawalsSweep()) + nextValidatorIndex %= math.ValidatorIndex(totalValidators) + } + + return st.SetNextWithdrawalValidatorIndex(nextValidatorIndex) +} diff --git a/mod/state-transition/pkg/core/deposits_validation.go b/mod/state-transition/pkg/core/validation_deposits.go similarity index 100% rename from mod/state-transition/pkg/core/deposits_validation.go rename to mod/state-transition/pkg/core/validation_deposits.go From 3136c14e61164bad57b4cc354c1d8cfc65ba808e Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 27 Nov 2024 20:35:11 -0500 Subject: [PATCH 50/53] devnet spec for e2e tests --- mod/config/pkg/spec/devnet.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mod/config/pkg/spec/devnet.go b/mod/config/pkg/spec/devnet.go index 6b13acac17..fa39cb9581 100644 --- a/mod/config/pkg/spec/devnet.go +++ b/mod/config/pkg/spec/devnet.go @@ -26,7 +26,8 @@ import ( "github.com/berachain/beacon-kit/mod/primitives/pkg/math" ) -// DevnetChainSpec is the ChainSpec for the localnet. +// DevnetChainSpec is the ChainSpec for the localnet. Also used for e2e tests +// in the kurtosis network. func DevnetChainSpec() (chain.Spec[ common.DomainType, math.Epoch, @@ -34,7 +35,11 @@ func DevnetChainSpec() (chain.Spec[ math.Slot, any, ], error) { - testnetSpec := BaseSpec() - testnetSpec.DepositEth1ChainID = DevnetEth1ChainID - return chain.NewChainSpec(testnetSpec) + devnetSpec := BaseSpec() + devnetSpec.DepositEth1ChainID = DevnetEth1ChainID + devnetSpec.EVMInflationAddress = common.NewExecutionAddressFromHex( + "0x6942069420694206942069420694206942069420", + ) + devnetSpec.EVMInflationPerBlock = 10e9 // 10e9 Bwei => 10 BERA per block. + return chain.NewChainSpec(devnetSpec) } From 2662284400c4a2378a47153bfc160907ae74ff59 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 28 Nov 2024 02:24:10 -0500 Subject: [PATCH 51/53] cleanup testing --- mod/config/pkg/spec/base.go | 123 ++++++++++++ .../pkg/spec/{constants.go => chain_ids.go} | 0 mod/config/pkg/spec/devnet.go | 13 +- mod/config/pkg/spec/special_cases.go | 4 +- mod/config/pkg/spec/testnet.go | 90 --------- testing/e2e/config/config.go | 174 ----------------- testing/e2e/config/defaults.go | 182 +++++++++++++++++- testing/e2e/e2e_staking_test.go | 17 +- testing/e2e/e2e_startup_test.go | 10 +- 9 files changed, 326 insertions(+), 287 deletions(-) create mode 100644 mod/config/pkg/spec/base.go rename mod/config/pkg/spec/{constants.go => chain_ids.go} (100%) diff --git a/mod/config/pkg/spec/base.go b/mod/config/pkg/spec/base.go new file mode 100644 index 0000000000..8f0ca9dc57 --- /dev/null +++ b/mod/config/pkg/spec/base.go @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package spec + +import ( + "github.com/berachain/beacon-kit/mod/chain-spec/pkg/chain" + "github.com/berachain/beacon-kit/mod/primitives/pkg/common" + "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto" + "github.com/berachain/beacon-kit/mod/primitives/pkg/math" + cmttypes "github.com/cometbft/cometbft/types" +) + +const ( + // Default DepositContractAddress is the default address of the pre-deployed + // beacon deposit contract. + DefaultDepositContractAddress = "0x4242424242424242424242424242424242424242" +) + +// BaseSpec returns a chain spec with default values. +// +//nolint:mnd // bet. +func BaseSpec() chain.SpecData[ + common.DomainType, + math.Epoch, + common.ExecutionAddress, + math.Slot, + any, +] { + cmtConsensusParams := cmttypes.DefaultConsensusParams() + cmtConsensusParams.Validator.PubKeyTypes = []string{crypto.CometBLSType} + + return chain.SpecData[ + common.DomainType, + math.Epoch, + common.ExecutionAddress, + math.Slot, + any, + ]{ + // Gwei value constants. + MinDepositAmount: 1e9, + MaxEffectiveBalance: 32e9, + EjectionBalance: 16e9, + EffectiveBalanceIncrement: 1e9, + // Time parameters constants. + SlotsPerEpoch: 32, + MinEpochsToInactivityPenalty: 4, + SlotsPerHistoricalRoot: 8, + // Signature domains. + DomainTypeProposer: common.DomainType{ + 0x00, 0x00, 0x00, 0x00, + }, + DomainTypeAttester: common.DomainType{ + 0x01, 0x00, 0x00, 0x00, + }, + DomainTypeRandao: common.DomainType{ + 0x02, 0x00, 0x00, 0x00, + }, + DomainTypeDeposit: common.DomainType{ + 0x03, 0x00, 0x00, 0x00, + }, + DomainTypeVoluntaryExit: common.DomainType{ + 0x04, 0x00, 0x00, 0x00, + }, + DomainTypeSelectionProof: common.DomainType{ + 0x05, 0x00, 0x00, 0x00, + }, + DomainTypeAggregateAndProof: common.DomainType{ + 0x06, 0x00, 0x00, 0x00, + }, + DomainTypeApplicationMask: common.DomainType{ + 0x00, 0x00, 0x00, 0x01, + }, + // Eth1-related values. + DepositContractAddress: common.NewExecutionAddressFromHex( + DefaultDepositContractAddress, + ), + DepositEth1ChainID: 1, + Eth1FollowDistance: 1, + TargetSecondsPerEth1Block: 3, + // Fork-related values. + DenebPlusForkEpoch: 9999999999999998, + ElectraForkEpoch: 9999999999999999, + // State list length constants. + EpochsPerHistoricalVector: 8, + EpochsPerSlashingsVector: 8, + HistoricalRootsLimit: 8, + ValidatorRegistryLimit: 1099511627776, + // Max operations per block constants. + MaxDepositsPerBlock: 16, + // Slashing + ProportionalSlashingMultiplier: 1, + // Capella values. + MaxWithdrawalsPerPayload: 16, + MaxValidatorsPerWithdrawalsSweep: 1 << 14, + // Deneb values. + MinEpochsForBlobsSidecarsRequest: 4096, + MaxBlobCommitmentsPerBlock: 16, + MaxBlobsPerBlock: 6, + FieldElementsPerBlob: 4096, + BytesPerBlob: 131072, + KZGCommitmentInclusionProofDepth: 17, + // Comet values. + CometValues: cmtConsensusParams, + } +} diff --git a/mod/config/pkg/spec/constants.go b/mod/config/pkg/spec/chain_ids.go similarity index 100% rename from mod/config/pkg/spec/constants.go rename to mod/config/pkg/spec/chain_ids.go diff --git a/mod/config/pkg/spec/devnet.go b/mod/config/pkg/spec/devnet.go index fa39cb9581..66c575ea2c 100644 --- a/mod/config/pkg/spec/devnet.go +++ b/mod/config/pkg/spec/devnet.go @@ -26,6 +26,15 @@ import ( "github.com/berachain/beacon-kit/mod/primitives/pkg/math" ) +const ( + // DevnetEVMInflationAddress is the address of the EVM inflation contract. + DevnetEVMInflationAddress = "0x6942069420694206942069420694206942069420" + + // DevnetEVMInflationPerBlock is the amount of native EVM balance (in units + // of Gwei) to be minted per EL block. + DevnetEVMInflationPerBlock = 10e9 +) + // DevnetChainSpec is the ChainSpec for the localnet. Also used for e2e tests // in the kurtosis network. func DevnetChainSpec() (chain.Spec[ @@ -38,8 +47,8 @@ func DevnetChainSpec() (chain.Spec[ devnetSpec := BaseSpec() devnetSpec.DepositEth1ChainID = DevnetEth1ChainID devnetSpec.EVMInflationAddress = common.NewExecutionAddressFromHex( - "0x6942069420694206942069420694206942069420", + DevnetEVMInflationAddress, ) - devnetSpec.EVMInflationPerBlock = 10e9 // 10e9 Bwei => 10 BERA per block. + devnetSpec.EVMInflationPerBlock = DevnetEVMInflationPerBlock return chain.NewChainSpec(devnetSpec) } diff --git a/mod/config/pkg/spec/special_cases.go b/mod/config/pkg/spec/special_cases.go index 36a55f1d17..236888eb7c 100644 --- a/mod/config/pkg/spec/special_cases.go +++ b/mod/config/pkg/spec/special_cases.go @@ -23,13 +23,13 @@ package spec // Special cased Bartio for some ad-hoc handling due to the way // some bugs were handled on Bartio. To be removed. const ( - BartioChainID uint64 = 80084 + BartioChainID = TestnetEth1ChainID //nolint:lll // temporary. BArtioValRoot = "0x9147586693b6e8faa837715c0f3071c2000045b54233901c2e7871b15872bc43" ) -// Planned hard-fork upgrades on boonet. +// Planned hard-fork upgrades on boonet. To be removed. const ( BoonetFork1Height uint64 = 69420 diff --git a/mod/config/pkg/spec/testnet.go b/mod/config/pkg/spec/testnet.go index ad71c356f7..aca8c25f8e 100644 --- a/mod/config/pkg/spec/testnet.go +++ b/mod/config/pkg/spec/testnet.go @@ -23,9 +23,7 @@ package spec import ( "github.com/berachain/beacon-kit/mod/chain-spec/pkg/chain" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" - "github.com/berachain/beacon-kit/mod/primitives/pkg/crypto" "github.com/berachain/beacon-kit/mod/primitives/pkg/math" - cmttypes "github.com/cometbft/cometbft/types" ) // TestnetChainSpec is the ChainSpec for the bArtio testnet. @@ -40,91 +38,3 @@ func TestnetChainSpec() (chain.Spec[ testnetSpec.DepositEth1ChainID = TestnetEth1ChainID return chain.NewChainSpec(testnetSpec) } - -// BaseSpec returns a chain spec with default values. -// -//nolint:mnd // bet. -func BaseSpec() chain.SpecData[ - common.DomainType, - math.Epoch, - common.ExecutionAddress, - math.Slot, - any, -] { - cmtConsensusParams := cmttypes.DefaultConsensusParams() - cmtConsensusParams.Validator.PubKeyTypes = []string{crypto.CometBLSType} - - return chain.SpecData[ - common.DomainType, - math.Epoch, - common.ExecutionAddress, - math.Slot, - any, - ]{ - // Gwei value constants. - MinDepositAmount: 1e9, - MaxEffectiveBalance: 32e9, - EjectionBalance: 16e9, - EffectiveBalanceIncrement: 1e9, - // Time parameters constants. - SlotsPerEpoch: 32, - MinEpochsToInactivityPenalty: 4, - SlotsPerHistoricalRoot: 8, - // Signature domains. - DomainTypeProposer: common.DomainType{ - 0x00, 0x00, 0x00, 0x00, - }, - DomainTypeAttester: common.DomainType{ - 0x01, 0x00, 0x00, 0x00, - }, - DomainTypeRandao: common.DomainType{ - 0x02, 0x00, 0x00, 0x00, - }, - DomainTypeDeposit: common.DomainType{ - 0x03, 0x00, 0x00, 0x00, - }, - DomainTypeVoluntaryExit: common.DomainType{ - 0x04, 0x00, 0x00, 0x00, - }, - DomainTypeSelectionProof: common.DomainType{ - 0x05, 0x00, 0x00, 0x00, - }, - DomainTypeAggregateAndProof: common.DomainType{ - 0x06, 0x00, 0x00, 0x00, - }, - DomainTypeApplicationMask: common.DomainType{ - 0x00, 0x00, 0x00, 0x01, - }, - // Eth1-related values. - DepositContractAddress: common.NewExecutionAddressFromHex( - "0x4242424242424242424242424242424242424242", - ), - DepositEth1ChainID: uint64(80084), - Eth1FollowDistance: 1, - TargetSecondsPerEth1Block: 3, - // Fork-related values. - DenebPlusForkEpoch: 9999999999999998, - ElectraForkEpoch: 9999999999999999, - // State list length constants. - EpochsPerHistoricalVector: 8, - EpochsPerSlashingsVector: 8, - HistoricalRootsLimit: 8, - ValidatorRegistryLimit: 1099511627776, - // Max operations per block constants. - MaxDepositsPerBlock: 16, - // Slashing - ProportionalSlashingMultiplier: 1, - // Capella values. - MaxWithdrawalsPerPayload: 16, - MaxValidatorsPerWithdrawalsSweep: 1 << 14, - // Deneb values. - MinEpochsForBlobsSidecarsRequest: 4096, - MaxBlobCommitmentsPerBlock: 16, - MaxBlobsPerBlock: 6, - FieldElementsPerBlob: 4096, - BytesPerBlob: 131072, - KZGCommitmentInclusionProofDepth: 17, - // Comet values. - CometValues: cmtConsensusParams, - } -} diff --git a/testing/e2e/config/config.go b/testing/e2e/config/config.go index 5e450ec77e..77c922f9d9 100644 --- a/testing/e2e/config/config.go +++ b/testing/e2e/config/config.go @@ -156,180 +156,6 @@ type AdditionalService struct { Replicas int `json:"replicas"` } -// DefaultE2ETestConfig provides a default configuration for end-to-end tests, -// pre-populating with a standard set of validators and no additional -// services. -func DefaultE2ETestConfig() *E2ETestConfig { - return &E2ETestConfig{ - NetworkConfiguration: defaultNetworkConfiguration(), - NodeSettings: defaultNodeSettings(), - EthJSONRPCEndpoints: defaultEthJSONRPCEndpoints(), - AdditionalServices: defaultAdditionalServices(), - } -} - -func defaultNetworkConfiguration() NetworkConfiguration { - return NetworkConfiguration{ - Validators: defaultValidators(), - FullNodes: defaultFullNodes(), - SeedNodes: defaultSeedNodes(), - } -} - -func defaultValidators() NodeSet { - return NodeSet{ - Type: "validator", - Nodes: []Node{ - { - ElType: "nethermind", - // TODO: restore once we solve - // https://github.com/berachain/beacon-kit/issues/2177 - Replicas: 0, // nethermind cannot keep up with deposits checks - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "geth", - Replicas: 2, //nolint:mnd // we want two replicas here - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "reth", - Replicas: 2, //nolint:mnd // we want two replicas here - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "erigon", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "besu", - Replicas: 0, // Besu causing flakey tests. - KZGImpl: "crate-crypto/go-kzg-4844", - }, - }, - } -} - -func defaultFullNodes() NodeSet { - return NodeSet{ - Type: "full", - Nodes: []Node{ - { - ElType: "nethermind", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "reth", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "geth", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "erigon", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - { - ElType: "besu", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - }, - } -} - -func defaultSeedNodes() NodeSet { - return NodeSet{ - Type: "seed", - Nodes: []Node{ - { - ElType: "geth", - Replicas: 1, - KZGImpl: "crate-crypto/go-kzg-4844", - }, - }, - } -} - -func defaultNodeSettings() NodeSettings { - return NodeSettings{ - ExecutionSettings: defaultExecutionSettings(), - ConsensusSettings: defaultConsensusSettings(), - } -} - -func defaultExecutionSettings() ExecutionSettings { - return ExecutionSettings{ - Specs: NodeSpecs{ - MinCPU: 0, - MaxCPU: 0, - MinMemory: 0, - MaxMemory: 2048, //nolint:mnd // 2 GB - }, - Images: map[string]string{ - "besu": "hyperledger/besu:24.5.4", - "erigon": "erigontech/erigon:v2.60.9", - "ethereumjs": "ethpandaops/ethereumjs:stable", - "geth": "ethereum/client-go:stable", - "nethermind": "nethermind/nethermind:latest", - "reth": "ghcr.io/paradigmxyz/reth:latest", - }, - } -} - -func defaultConsensusSettings() ConsensusSettings { - return ConsensusSettings{ - Specs: NodeSpecs{ - MinCPU: 0, - MaxCPU: 2000, //nolint:mnd // 2 vCPUs - MinMemory: 0, - MaxMemory: 2048, //nolint:mnd // 2 GB - }, - Images: map[string]string{ - "beaconkit": "beacond:kurtosis-local", - }, - Config: ConsensusConfig{ - TimeoutPropose: "3s", - TimeoutPrevote: "1s", - TimeoutPrecommit: "1s", - TimeoutCommit: "3s", - MaxNumInboundPeers: 40, //nolint:mnd // 40 inbound peers - MaxNumOutboundPeers: 10, //nolint:mnd // 10 outbound peers - }, - AppConfig: AppConfig{ - PayloadTimeout: "1.5s", - EnableOptimisticPayloadBuilds: false, - }, - } -} - -func defaultEthJSONRPCEndpoints() []EthJSONRPCEndpoint { - return []EthJSONRPCEndpoint{ - { - Type: "blutgang", - Clients: []string{ - // "el-full-nethermind-0", - // "el-full-reth-0", - "el-full-geth-2", - // "el-full-erigon-3", - // "el-full-erigon-3", - // Besu causing flakey tests. - // "el-full-besu-4", - }, - }, - } -} - -func defaultAdditionalServices() []AdditionalService { - return []AdditionalService{} -} - // MustMarshalJSON marshals the E2ETestConfig to JSON, panicking if an error. func (c *E2ETestConfig) MustMarshalJSON() []byte { jsonBytes, err := json.Marshal(c) diff --git a/testing/e2e/config/defaults.go b/testing/e2e/config/defaults.go index 4ab358c787..28127fb7be 100644 --- a/testing/e2e/config/defaults.go +++ b/testing/e2e/config/defaults.go @@ -26,14 +26,176 @@ const ( AlternateClient = "cl-validator-beaconkit-1" ) -// Deposits. -const ( - DepositContractAddress = "0x4242424242424242424242424242424242424242" - NumDepositsLoad = 500 -) +// DefaultE2ETestConfig provides a default configuration for end-to-end tests, +// pre-populating with a standard set of validators and no additional +// services. +func DefaultE2ETestConfig() *E2ETestConfig { + return &E2ETestConfig{ + NetworkConfiguration: defaultNetworkConfiguration(), + NodeSettings: defaultNodeSettings(), + EthJSONRPCEndpoints: defaultEthJSONRPCEndpoints(), + AdditionalServices: defaultAdditionalServices(), + } +} -// EVM Inflation. -const ( - EVMInflationAddress = "0x6942069420694206942069420694206942069420" - EVMInflationPerBlockWei = 10e18 -) +func defaultNetworkConfiguration() NetworkConfiguration { + return NetworkConfiguration{ + Validators: defaultValidators(), + FullNodes: defaultFullNodes(), + SeedNodes: defaultSeedNodes(), + } +} + +func defaultValidators() NodeSet { + return NodeSet{ + Type: "validator", + Nodes: []Node{ + { + ElType: "nethermind", + // TODO: restore once we solve + // https://github.com/berachain/beacon-kit/issues/2177 + Replicas: 0, // nethermind cannot keep up with deposits checks + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "geth", + Replicas: 2, //nolint:mnd // we want two replicas here + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "reth", + Replicas: 2, //nolint:mnd // we want two replicas here + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "erigon", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "besu", + Replicas: 0, // Besu causing flakey tests. + KZGImpl: "crate-crypto/go-kzg-4844", + }, + }, + } +} + +func defaultFullNodes() NodeSet { + return NodeSet{ + Type: "full", + Nodes: []Node{ + { + ElType: "nethermind", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "reth", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "geth", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "erigon", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + { + ElType: "besu", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + }, + } +} + +func defaultSeedNodes() NodeSet { + return NodeSet{ + Type: "seed", + Nodes: []Node{ + { + ElType: "geth", + Replicas: 1, + KZGImpl: "crate-crypto/go-kzg-4844", + }, + }, + } +} + +func defaultNodeSettings() NodeSettings { + return NodeSettings{ + ExecutionSettings: defaultExecutionSettings(), + ConsensusSettings: defaultConsensusSettings(), + } +} + +func defaultExecutionSettings() ExecutionSettings { + return ExecutionSettings{ + Specs: NodeSpecs{ + MinCPU: 0, + MaxCPU: 0, + MinMemory: 0, + MaxMemory: 2048, //nolint:mnd // 2 GB + }, + Images: map[string]string{ + "besu": "hyperledger/besu:24.5.4", + "erigon": "erigontech/erigon:v2.60.9", + "ethereumjs": "ethpandaops/ethereumjs:stable", + "geth": "ethereum/client-go:stable", + "nethermind": "nethermind/nethermind:latest", + "reth": "ghcr.io/paradigmxyz/reth:latest", + }, + } +} + +func defaultConsensusSettings() ConsensusSettings { + return ConsensusSettings{ + Specs: NodeSpecs{ + MinCPU: 0, + MaxCPU: 2000, //nolint:mnd // 2 vCPUs + MinMemory: 0, + MaxMemory: 2048, //nolint:mnd // 2 GB + }, + Images: map[string]string{ + "beaconkit": "beacond:kurtosis-local", + }, + Config: ConsensusConfig{ + TimeoutPropose: "3s", + TimeoutPrevote: "1s", + TimeoutPrecommit: "1s", + TimeoutCommit: "3s", + MaxNumInboundPeers: 40, //nolint:mnd // 40 inbound peers + MaxNumOutboundPeers: 10, //nolint:mnd // 10 outbound peers + }, + AppConfig: AppConfig{ + PayloadTimeout: "1.5s", + EnableOptimisticPayloadBuilds: false, + }, + } +} + +func defaultEthJSONRPCEndpoints() []EthJSONRPCEndpoint { + return []EthJSONRPCEndpoint{ + { + Type: "blutgang", + Clients: []string{ + // "el-full-nethermind-0", + // "el-full-reth-0", + "el-full-geth-2", + // "el-full-erigon-3", + // "el-full-erigon-3", + // Besu causing flakey tests. + // "el-full-besu-4", + }, + }, + } +} + +func defaultAdditionalServices() []AdditionalService { + return []AdditionalService{} +} diff --git a/testing/e2e/e2e_staking_test.go b/testing/e2e/e2e_staking_test.go index a897fa6cc7..8f67cc3a18 100644 --- a/testing/e2e/e2e_staking_test.go +++ b/testing/e2e/e2e_staking_test.go @@ -23,6 +23,7 @@ package e2e_test import ( "math/big" + "github.com/berachain/beacon-kit/mod/config/pkg/spec" "github.com/berachain/beacon-kit/mod/consensus-types/pkg/types" "github.com/berachain/beacon-kit/mod/geth-primitives/pkg/deposit" "github.com/berachain/beacon-kit/mod/primitives/pkg/common" @@ -33,6 +34,12 @@ import ( coretypes "github.com/ethereum/go-ethereum/core/types" ) +const ( + // NumDepositsLoad is the number of deposits to load in the Deposit + // Robustness e2e test. + NumDepositsLoad = 500 +) + func (s *BeaconKitE2ESuite) TestDepositRobustness() { // Get the consensus client. client := s.ConsensusClients()[config.DefaultClient] @@ -73,7 +80,7 @@ func (s *BeaconKitE2ESuite) TestDepositRobustness() { // Bind the deposit contract. dc, err := deposit.NewBeaconDepositContract( - gethcommon.HexToAddress(config.DepositContractAddress), + gethcommon.HexToAddress(spec.DefaultDepositContractAddress), s.JSONRPCBalancer(), ) s.Require().NoError(err) @@ -81,7 +88,7 @@ func (s *BeaconKitE2ESuite) TestDepositRobustness() { tx, err := dc.AllowDeposit(&bind.TransactOpts{ From: genesisAccount.Address(), Signer: genesisAccount.SignerFunc(chainID), - }, sender.Address(), config.NumDepositsLoad) + }, sender.Address(), NumDepositsLoad) s.Require().NoError(err) // Wait for the transaction to be mined. @@ -97,7 +104,7 @@ func (s *BeaconKitE2ESuite) TestDepositRobustness() { ) s.Require().NoError(err) - for i := range config.NumDepositsLoad { + for i := range NumDepositsLoad { // Create a deposit transaction. tx, err = s.generateNewDepositTx( dc, @@ -108,7 +115,7 @@ func (s *BeaconKitE2ESuite) TestDepositRobustness() { s.Require().NoError(err) s.Logger(). Info("Deposit transaction created", "txHash", tx.Hash().Hex()) - if i == config.NumDepositsLoad-1 { + if i == NumDepositsLoad-1 { s.Logger().Info( "Waiting for deposit transaction to be mined", "txHash", tx.Hash().Hex(), @@ -141,7 +148,7 @@ func (s *BeaconKitE2ESuite) TestDepositRobustness() { // lower bound: 32ether * 500 oneEther := big.NewInt(1e18) totalAmt := new(big.Int).Mul( - oneEther, big.NewInt(config.NumDepositsLoad*32), + oneEther, big.NewInt(NumDepositsLoad*32), ) upperBound := new(big.Int).Add(totalAmt, oneEther) amtSpent := new(big.Int).Sub(balance, postDepositBalance) diff --git a/testing/e2e/e2e_startup_test.go b/testing/e2e/e2e_startup_test.go index 52665490af..0c86afef96 100644 --- a/testing/e2e/e2e_startup_test.go +++ b/testing/e2e/e2e_startup_test.go @@ -23,7 +23,8 @@ package e2e_test import ( "math/big" - "github.com/berachain/beacon-kit/testing/e2e/config" + "github.com/berachain/beacon-kit/mod/config/pkg/spec" + "github.com/berachain/beacon-kit/mod/primitives/pkg/math" "github.com/berachain/beacon-kit/testing/e2e/suite" gethcommon "github.com/ethereum/go-ethereum/common" ) @@ -45,17 +46,18 @@ func (s *BeaconKitE2ESuite) TestBasicStartup() { // amount of EVM inflation per block. func (s *BeaconKitE2ESuite) TestEVMInflation() { evmInflationPerBlockWei, _ := big.NewFloat( - config.EVMInflationPerBlockWei).Int(nil) + spec.DevnetEVMInflationPerBlock * math.GweiPerWei, + ).Int(nil) // Check over the next 10 EVM blocks, that after every block, the balance - // of the EVM inflation address increases by EVMInflationPerBlockWei. + // of the EVM inflation address increases by DevnetEVMInflationPerBlock. for i := int64(0); i <= 10; i++ { err := s.WaitForFinalizedBlockNumber(uint64(i)) s.Require().NoError(err) balance, err := s.JSONRPCBalancer().BalanceAt( s.Ctx(), - gethcommon.HexToAddress(config.EVMInflationAddress), + gethcommon.HexToAddress(spec.DevnetEVMInflationAddress), big.NewInt(i), ) s.Require().NoError(err) From 24b9f21cdf2518c478a4b9fc248d8d6fa1f00a45 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 28 Nov 2024 02:25:41 -0500 Subject: [PATCH 52/53] naming cleaned --- mod/state-transition/pkg/core/state_processor_withdrawals.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/state-transition/pkg/core/state_processor_withdrawals.go b/mod/state-transition/pkg/core/state_processor_withdrawals.go index d9f80870c6..a3e096b2ba 100644 --- a/mod/state-transition/pkg/core/state_processor_withdrawals.go +++ b/mod/state-transition/pkg/core/state_processor_withdrawals.go @@ -72,8 +72,8 @@ func (sp *StateProcessor[ ) error { slot, err := st.GetSlot() if err != nil { - return fmt.Errorf( - "failed loading slot while processing deposits: %w", err, + return errors.Wrap( + err, "failed loading slot while processing withdrawals", ) } From afdf51dc41fa6b551e019ed55fd6199fb9165818 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 28 Nov 2024 02:32:02 -0500 Subject: [PATCH 53/53] tidy sync --- testing/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/go.mod b/testing/go.mod index 68aa0081b8..e1c5a338e8 100644 --- a/testing/go.mod +++ b/testing/go.mod @@ -5,6 +5,7 @@ go 1.23.0 require ( cosmossdk.io/log v1.4.1 github.com/attestantio/go-eth2-client v0.21.10 + github.com/berachain/beacon-kit/mod/config v0.0.0-20240705193247-d464364483df github.com/berachain/beacon-kit/mod/consensus-types v0.0.0-20240806160829-cde2d1347e7e github.com/berachain/beacon-kit/mod/errors v0.0.0-20240705193247-d464364483df github.com/berachain/beacon-kit/mod/geth-primitives v0.0.0-20240806160829-cde2d1347e7e @@ -30,7 +31,6 @@ require ( github.com/adrg/xdg v0.4.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240705193247-d464364483df // indirect - github.com/berachain/beacon-kit/mod/config v0.0.0-20240705193247-d464364483df // indirect github.com/berachain/beacon-kit/mod/engine-primitives v0.0.0-20240808194557-e72e74f58197 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect