From 15147cccb1a45f65556b563f8bc8693d5f020589 Mon Sep 17 00:00:00 2001 From: andri lim Date: Tue, 12 Dec 2023 22:15:00 +0700 Subject: [PATCH] Bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354 (#5664) * bump nim-web3 to dcabb8f29ee55afedefdf93cd3e102bb1daee354 also bump json-rpc to a8731e91bc336d930ac66f985d3b88ed7cf2a7d7 --- beacon_chain/conf.nim | 2 +- .../consensus_manager.nim | 2 +- beacon_chain/el/deposit_contract.nim | 18 +++++----- beacon_chain/el/deposit_contract_code.txt | 2 +- beacon_chain/libnimbus_lc/libnimbus_lc.nim | 34 ++++++++++++------- beacon_chain/networking/network_metadata.nim | 7 ++-- .../eth2_apis/eth2_rest_serialization.nim | 4 +-- beacon_chain/spec/eth2_apis/rest_types.nim | 2 +- beacon_chain/spec/presets.nim | 6 ++-- beacon_chain/validators/beacon_validators.nim | 2 +- ncli/deposit_downloader.nim | 2 +- ncli/ncli_testnet.nim | 18 +++++----- research/fakeee.nim | 2 +- tests/test_helpers.nim | 2 +- vendor/nim-json-rpc | 2 +- vendor/nim-web3 | 2 +- 16 files changed, 57 insertions(+), 50 deletions(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 18184c338..b05acd76d 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -20,7 +20,7 @@ import stew/[io2, byteutils], unicodedb/properties, normalize, eth/common/eth_types as commonEthTypes, eth/net/nat, eth/p2p/discoveryv5/enr, - json_serialization, web3/[ethtypes, confutils_defs], + json_serialization, web3/[primitives, confutils_defs], kzg4844/kzg_ex, ./spec/[engine_authentication, keystore, network, crypto], ./spec/datatypes/base, diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index c72e46caa..af9fdbf2d 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -8,7 +8,7 @@ {.push raises: [].} import - chronicles, chronos, web3/[ethtypes, engine_api_types], + chronicles, chronos, web3/[primitives, engine_api_types], ../spec/datatypes/base, ../consensus_object_pools/[blockchain_dag, block_quarantine, attestation_pool], ../el/el_manager, diff --git a/beacon_chain/el/deposit_contract.nim b/beacon_chain/el/deposit_contract.nim index f40ec10d4..2fc47212a 100644 --- a/beacon_chain/el/deposit_contract.nim +++ b/beacon_chain/el/deposit_contract.nim @@ -13,14 +13,15 @@ import ../filepath, ../networking/network_metadata, web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2, - stew/io2, + stew/[io2, byteutils], ../spec/eth2_merkleization, ../spec/datatypes/base, ../validators/keystore_management # Compiled version of /scripts/depositContract.v.py in this repo # The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler. -const contractCode = staticRead "deposit_contract_code.txt" +const contractCode = + hexToSeqByte staticRead "deposit_contract_code.txt" type Eth1Address = web3.Address @@ -120,24 +121,21 @@ contract(DepositContract): signature: SignatureBytes, deposit_data_root: FixedBytes[32]) -proc deployContract*(web3: Web3, code: string): Future[ReceiptObject] {.async.} = - var code = code - if code[1] notin {'x', 'X'}: - code = "0x" & code +proc deployContract*(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = EthSend( - source: web3.defaultAccount, + `from`: web3.defaultAccount, data: code, gas: Quantity(3000000).some, - gasPrice: 1.some) + gasPrice: Quantity(1).some) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = EthSend( - source: web3.defaultAccount, + `from`: web3.defaultAccount, gas: Quantity(3000000).some, - gasPrice: 1.some, + gasPrice: Quantity(1).some, value: some(valueEth.u256 * 1000000000000000000.u256), to: some(to)) web3.send(tr) diff --git a/beacon_chain/el/deposit_contract_code.txt b/beacon_chain/el/deposit_contract_code.txt index 11ad01f1a..3a2270b2a 100644 --- a/beacon_chain/el/deposit_contract_code.txt +++ b/beacon_chain/el/deposit_contract_code.txt @@ -1 +1 @@ -0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009857600080fd5b336003556101406000601f818352015b600061014051602081106100bb57600080fd5b600260c052602060c020015460208261016001015260208101905061014051602081106100e757600080fd5b600260c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012557600080fd5b60c0519050606051600161014051018060405190131561014457600080fd5b809190121561015257600080fd5b6020811061015f57600080fd5b600260c052602060c02001555b81516001018083528114156100a8575b505061129656600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610277575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156102025761021e565b6000610320516102e001535b81516001018083528114156101f2575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102535761026f565b602061028051036102a001516020610280510361028052610241565b610160515650005b63c5f2892f600051141561050957341561029057600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103325760006101a051602081106102d357600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161032457600080fd5b60c0519050610160526103a0565b6000610160516020826101c00101526020810190506101a0516020811061035857600080fd5b600260c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161039657600080fd5b60c0519050610160525b61018060026103ae57600080fd5b60028151048152505b81516001018083528114156102b1575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104355761044e565b6103c05161038001526103c0516020016103c052610413565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561049957600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104f957600080fd5b60c051905060005260206000f350005b63621fd130600051141561061c57341561052257600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561056d57610586565b610220516101e00152610220516020016102205261054b565b6101c0805160200180610280828460006004600a8704601201f16105a957600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156105db576105f7565b60006102e0516102a001535b81516001018083528114156105cb575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110d957605060043560040161014037603060043560040135111561064a57600080fd5b60406024356004016101c037602060243560040135111561066a57600080fd5b608060443560040161022037606060443560040135111561068a57600080fd5b63ffffffff6001541061069c57600080fd5b633b9aca006102e0526102e0516106b257600080fd5b6102e05134046102c052633b9aca006102c05110156106d057600080fd5b603061014051146106e057600080fd5b60206101c051146106f057600080fd5b6060610220511461070057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561072a57610708565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107765761078f565b6104605161042001526104605160200161046052610754565b610340610360525b61036051526020610360510361036052610140610360511015156107ba57610797565b610400805160200180610300828460006004600a8704601201f16107dd57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610809576107e7565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108545761086d565b6105805161054001526105805160200161058052610832565b610460610480525b610480515260206104805103610480526101406104805110151561089857610875565b6105208051602001806105a0828460006004600a8704601201f16108bb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108f357600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516040818352015b83610600511015156109315761094e565b6000610600516020850101535b8151600101808352811415610920575b50505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109a557600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b83610600511015156109e357610a00565b6000610600516020850101535b81516001018083528114156109d2575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a5757600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b8361060051101515610a9557610ab2565b6000610600516020850101535b8151600101808352811415610a84575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b0957600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516060818352015b8361060051101515610b4757610b64565b6000610600516020850101535b8151600101808352811415610b36575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bbb57600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b8361060051101515610bf957610c16565b6000610600516020850101535b8151600101808352811415610be8575b50505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cad57600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d0d57600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d3657600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d7657600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610daa57600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e2757600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e5e57600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ec457600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f1957600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f8c57600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fc357600080fd5b60c0519050610ae052606435610ae05114610fdd57600080fd5b6001805460018254011015610ff157600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561104157610ae051610d20516020811061103057600080fd5b600060c052602060c02001556110d5565b6000610d20516020811061105457600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110a557600080fd5b60c0519050610ae052610d0060026110bc57600080fd5b60028151048152505b815160010180835281141561100c575b5050005b639890220b600051141561110d5734156110f257600080fd5b600060006000600030316003546000f161110b57600080fd5b005b60006000fd5b61018361129603610183600039610183611296036000f3 +0x740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052341561009857600080fd5b336003556101406000601f818352015b600061014051602081106100bb57600080fd5b600260c052602060c020015460208261016001015260208101905061014051602081106100e757600080fd5b600260c052602060c020015460208261016001015260208101905080610160526101609050602060c0825160208401600060025af161012557600080fd5b60c0519050606051600161014051018060405190131561014457600080fd5b809190121561015257600080fd5b6020811061015f57600080fd5b600260c052602060c02001555b81516001018083528114156100a8575b505061129656600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052600015610277575b6101605261014052600061018052610140516101a0526101c060006008818352015b61018051600860008112156100da578060000360020a82046100e1565b8060020a82025b905090506101805260ff6101a051166101e052610180516101e0516101805101101561010c57600080fd5b6101e0516101805101610180526101a0517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff86000811215610155578060000360020a820461015c565b8060020a82025b905090506101a0525b81516001018083528114156100bd575b50506018600860208206610200016020828401111561019357600080fd5b60208061022082610180600060046015f15050818152809050905090508051602001806102c0828460006004600a8704601201f16101d057600080fd5b50506102c05160206001820306601f82010390506103206102c0516008818352015b826103205111156102025761021e565b6000610320516102e001535b81516001018083528114156101f2575b50505060206102a05260406102c0510160206001820306601f8201039050610280525b6000610280511115156102535761026f565b602061028051036102a001516020610280510361028052610241565b610160515650005b63c5f2892f600051141561050957341561029057600080fd5b6000610140526101405161016052600154610180526101a060006020818352015b60016001610180511614156103325760006101a051602081106102d357600080fd5b600060c052602060c02001546020826102400101526020810190506101605160208261024001015260208101905080610240526102409050602060c0825160208401600060025af161032457600080fd5b60c0519050610160526103a0565b6000610160516020826101c00101526020810190506101a0516020811061035857600080fd5b600260c052602060c02001546020826101c0010152602081019050806101c0526101c09050602060c0825160208401600060025af161039657600080fd5b60c0519050610160525b61018060026103ae57600080fd5b60028151048152505b81516001018083528114156102b1575b505060006101605160208261046001015260208101905061014051610160516101805163806732896102e05260015461030052610300516006580161009b565b506103605260006103c0525b6103605160206001820306601f82010390506103c0511015156104355761044e565b6103c05161038001526103c0516020016103c052610413565b61018052610160526101405261036060088060208461046001018260208501600060046012f150508051820191505060006018602082066103e0016020828401111561049957600080fd5b60208061040082610140600060046015f150508181528090509050905060188060208461046001018260208501600060046014f150508051820191505080610460526104609050602060c0825160208401600060025af16104f957600080fd5b60c051905060005260206000f350005b63621fd130600051141561061c57341561052257600080fd5b63806732896101405260015461016052610160516006580161009b565b506101c0526000610220525b6101c05160206001820306601f82010390506102205110151561056d57610586565b610220516101e00152610220516020016102205261054b565b6101c0805160200180610280828460006004600a8704601201f16105a957600080fd5b50506102805160206001820306601f82010390506102e0610280516008818352015b826102e05111156105db576105f7565b60006102e0516102a001535b81516001018083528114156105cb575b5050506020610260526040610280510160206001820306601f8201039050610260f350005b632289511860005114156110d957605060043560040161014037603060043560040135111561064a57600080fd5b60406024356004016101c037602060243560040135111561066a57600080fd5b608060443560040161022037606060443560040135111561068a57600080fd5b63ffffffff6001541061069c57600080fd5b633b9aca006102e0526102e0516106b257600080fd5b6102e05134046102c052633b9aca006102c05110156106d057600080fd5b603061014051146106e057600080fd5b60206101c051146106f057600080fd5b6060610220511461070057600080fd5b610140610360525b6103605151602061036051016103605261036061036051101561072a57610708565b6380673289610380526102c0516103a0526103a0516006580161009b565b50610400526000610460525b6104005160206001820306601f8201039050610460511015156107765761078f565b6104605161042001526104605160200161046052610754565b610340610360525b61036051526020610360510361036052610140610360511015156107ba57610797565b610400805160200180610300828460006004600a8704601201f16107dd57600080fd5b5050610140610480525b61048051516020610480510161048052610480610480511015610809576107e7565b63806732896104a0526001546104c0526104c0516006580161009b565b50610520526000610580525b6105205160206001820306601f8201039050610580511015156108545761086d565b6105805161054001526105805160200161058052610832565b610460610480525b610480515260206104805103610480526101406104805110151561089857610875565b6105208051602001806105a0828460006004600a8704601201f16108bb57600080fd5b505060a06106205261062051610660526101408051602001806106205161066001828460006004600a8704601201f16108f357600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516040818352015b83610600511015156109315761094e565b6000610600516020850101535b8151600101808352811415610920575b50505050602061062051610660015160206001820306601f82010390506106205101016106205261062051610680526101c08051602001806106205161066001828460006004600a8704601201f16109a557600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b83610600511015156109e357610a00565b6000610600516020850101535b81516001018083528114156109d2575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106a0526103008051602001806106205161066001828460006004600a8704601201f1610a5757600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b8361060051101515610a9557610ab2565b6000610600516020850101535b8151600101808352811415610a84575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106c0526102208051602001806106205161066001828460006004600a8704601201f1610b0957600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516060818352015b8361060051101515610b4757610b64565b6000610600516020850101535b8151600101808352811415610b36575b50505050602061062051610660015160206001820306601f820103905061062051010161062052610620516106e0526105a08051602001806106205161066001828460006004600a8704601201f1610bbb57600080fd5b505061062051610660015160206001820306601f8201039050610620516106600161060081516020818352015b8361060051101515610bf957610c16565b6000610600516020850101535b8151600101808352811415610be8575b50505050602061062051610660015160206001820306601f8201039050610620510101610620527f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c561062051610660a160006107005260006101406030806020846107c001018260208501600060046016f150508051820191505060006010602082066107400160208284011115610cad57600080fd5b60208061076082610700600060046015f15050818152809050905090506010806020846107c001018260208501600060046013f1505080518201915050806107c0526107c09050602060c0825160208401600060025af1610d0d57600080fd5b60c0519050610720526000600060406020820661086001610220518284011115610d3657600080fd5b606080610880826020602088068803016102200160006004601bf1505081815280905090509050602060c0825160208401600060025af1610d7657600080fd5b60c0519050602082610a600101526020810190506000604060206020820661092001610220518284011115610daa57600080fd5b606080610940826020602088068803016102200160006004601bf15050818152809050905090506020806020846109e001018260208501600060046015f1505080518201915050610700516020826109e0010152602081019050806109e0526109e09050602060c0825160208401600060025af1610e2757600080fd5b60c0519050602082610a6001015260208101905080610a6052610a609050602060c0825160208401600060025af1610e5e57600080fd5b60c0519050610840526000600061072051602082610b000101526020810190506101c0602080602084610b0001018260208501600060046015f150508051820191505080610b0052610b009050602060c0825160208401600060025af1610ec457600080fd5b60c0519050602082610c800101526020810190506000610300600880602084610c0001018260208501600060046012f15050805182019150506000601860208206610b800160208284011115610f1957600080fd5b602080610ba082610700600060046015f1505081815280905090509050601880602084610c0001018260208501600060046014f150508051820191505061084051602082610c0001015260208101905080610c0052610c009050602060c0825160208401600060025af1610f8c57600080fd5b60c0519050602082610c8001015260208101905080610c8052610c809050602060c0825160208401600060025af1610fc357600080fd5b60c0519050610ae052606435610ae05114610fdd57600080fd5b6001805460018254011015610ff157600080fd5b6001815401815550600154610d0052610d2060006020818352015b60016001610d005116141561104157610ae051610d20516020811061103057600080fd5b600060c052602060c02001556110d5565b6000610d20516020811061105457600080fd5b600060c052602060c0200154602082610d40010152602081019050610ae051602082610d4001015260208101905080610d4052610d409050602060c0825160208401600060025af16110a557600080fd5b60c0519050610ae052610d0060026110bc57600080fd5b60028151048152505b815160010180835281141561100c575b5050005b639890220b600051141561110d5734156110f257600080fd5b600060006000600030316003546000f161110b57600080fd5b005b60006000fd5b61018361129603610183600039610183611296036000f3 \ No newline at end of file diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index 6685e0c3c..f27a6d37d 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -17,7 +17,7 @@ import eth/trie/[db, hexary], json_rpc/jsonmarshal, secp256k1, - web3/ethtypes, + web3/eth_api_types, ../el/el_manager, ../spec/eth2_apis/[eth2_rest_serialization, rest_light_client_calls], ../spec/[helpers, light_client_sync], @@ -1501,7 +1501,7 @@ proc ETHTransactionsCreateFromJson( doAssert sizeof(int64) == sizeof(data.gasPrice) doAssert sizeof(int64) == sizeof(data.maxPriorityFeePerGas.get) doAssert sizeof(UInt256) == sizeof(data.maxFeePerBlobGas.get) - if data.chainId.get(default(UInt256)) > distinctBase(ChainId.high).u256: + if distinctBase(data.chainId.get(0.Quantity)) > distinctBase(ChainId.high): return nil if distinctBase(data.gasPrice) > int64.high.uint64: return nil @@ -1515,12 +1515,12 @@ proc ETHTransactionsCreateFromJson( return nil if distinctBase(data.gas) > int64.high.uint64: return nil - if data.v > int64.high.u256: + if data.v.uint64 > int64.high.uint64: return nil let tx = ExecutionTransaction( txType: txType, - chainId: data.chainId.get(default(UInt256)).truncate(uint64).ChainId, + chainId: data.chainId.get(0.Quantity).ChainId, nonce: distinctBase(data.nonce), gasPrice: data.gasPrice.GasInt, maxPriorityFee: @@ -1549,7 +1549,7 @@ proc ETHTransactionsCreateFromJson( ExecutionHash256(data: distinctBase(it))) else: @[], - V: data.v.truncate(uint64).int64, + V: data.v.int64, R: data.r, S: data.s) rlpBytes = @@ -2105,7 +2105,7 @@ proc ETHReceiptsCreateFromJson( return nil # Check fork consistency - static: doAssert totalSerializedFields(ReceiptObject) == 15, + static: doAssert totalSerializedFields(ReceiptObject) == 17, "Only update this number once code is adjusted to check new fields!" static: doAssert totalSerializedFields(LogObject) == 9, "Only update this number once code is adjusted to check new fields!" @@ -2133,16 +2133,26 @@ proc ETHReceiptsCreateFromJson( for log in data.logs: if log.removed: return nil - if distinctBase(log.logIndex) != logIndex + 1: + if log.logIndex.isNone: return nil - logIndex = distinctBase(log.logIndex) - if log.transactionIndex != data.transactionIndex: + if distinctBase(log.logIndex.get) != logIndex + 1: return nil - if log.transactionHash != data.transactionHash: + logIndex = distinctBase(log.logIndex.get) + if log.transactionIndex.isNone: return nil - if log.blockHash != data.blockHash: + if log.transactionIndex.get != data.transactionIndex: return nil - if log.blockNumber != data.blockNumber: + if log.transactionHash.isNone: + return nil + if log.transactionHash.get != data.transactionHash: + return nil + if log.blockHash.isNone: + return nil + if log.blockHash.get != data.blockHash: + return nil + if log.blockNumber.isNone: + return nil + if log.blockNumber.get != data.blockNumber: return nil if log.data.len mod 32 != 0: return nil diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 2a852c0bd..fcdfbcdb8 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -10,7 +10,8 @@ import std/[sequtils, strutils, os], stew/[byteutils, objects], stew/shims/macros, nimcrypto/hash, - web3/[ethtypes, conversions], + web3/[conversions], + web3/primitives as web3types, chronicles, eth/common/eth_types_json_serialization, ../spec/[eth2_ssz_serialization, forks] @@ -29,7 +30,7 @@ import # from `currentSourcePath`. export - ethtypes, conversions, RuntimeConfig + web3types, conversions, RuntimeConfig const vendorDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor" @@ -37,7 +38,7 @@ const incbinEnabled* = sizeof(pointer) == 8 type - Eth1BlockHash* = ethtypes.BlockHash + Eth1BlockHash* = web3types.BlockHash Eth1Network* = enum mainnet diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index f6b63e696..73f0c4d5b 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -27,8 +27,8 @@ export eth2_ssz_serialization, results, peerid, common, serialization, chronicles, json_serialization, net, sets, rest_types, slashing_protection_common -from web3/ethtypes import BlockHash -export ethtypes.BlockHash +from web3/primitives import BlockHash +export primitives.BlockHash func decodeMediaType*( contentType: Opt[ContentTypeData]): Result[MediaType, string] = diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index 838959369..d6bc58a12 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -15,7 +15,7 @@ import std/[json, tables], - stew/base10, web3/ethtypes, httputils, + stew/base10, web3/primitives, httputils, ".."/forks, ".."/datatypes/[phase0, altair, bellatrix, deneb], ".."/mev/[capella_mev, deneb_mev] diff --git a/beacon_chain/spec/presets.nim b/beacon_chain/spec/presets.nim index 2b13354a3..8c9b538f7 100644 --- a/beacon_chain/spec/presets.nim +++ b/beacon_chain/spec/presets.nim @@ -10,12 +10,12 @@ import std/[strutils, parseutils, tables, typetraits], chronos/timer, - stew/[byteutils], stint, web3/[ethtypes], + stew/[byteutils], stint, web3/primitives as web3types, ./datatypes/constants export constants -export stint, ethtypes.toHex, ethtypes.`==` +export stint, web3types.toHex, web3types.`==` const # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/beacon-chain.md#withdrawal-prefixes @@ -33,7 +33,7 @@ const type Version* = distinct array[4, byte] - Eth1Address* = ethtypes.Address + Eth1Address* = web3types.Address RuntimeConfig* = object ## https://github.com/ethereum/consensus-specs/tree/v1.4.0-beta.4/configs diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index d6ea5caa6..e908f3b7b 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -23,7 +23,7 @@ import chronicles, chronicles/timings, json_serialization/std/[options, sets, net], eth/db/kvstore, - web3/ethtypes, + web3/primitives, kzg4844, # Local modules diff --git a/ncli/deposit_downloader.nim b/ncli/deposit_downloader.nim index caa7862f7..5873de50a 100644 --- a/ncli/deposit_downloader.nim +++ b/ncli/deposit_downloader.nim @@ -8,7 +8,7 @@ import std/[json, strutils, times, sequtils], chronos, confutils, chronicles, - web3, web3/ethtypes as web3Types, + web3, web3/primitives, eth/async_utils, ../beacon_chain/beacon_chain_db, ../beacon_chain/networking/network_metadata, diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index 35ac9e665..d29aa0dd8 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -29,7 +29,8 @@ from std/times import toUnix # Compiled version of /scripts/depositContract.v.py in this repo # The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler. -const depositContractCode = staticRead "../beacon_chain/el/deposit_contract_code.txt" +const depositContractCode = + hexToSeqByte staticRead "../beacon_chain/el/deposit_contract_code.txt" # For nim-confutils, which uses this kind of init(Type, value) pattern func init(T: type IpAddress, ip: IpAddress): T = ip @@ -282,7 +283,7 @@ contract(DepositContract): signature: SignatureBytes, deposit_data_root: FixedBytes[32]) -template `as`(address: ethtypes.Address, T: type bellatrix.ExecutionAddress): T = +template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T = T(data: distinctBase(address)) template `as`(address: BlockHash, T: type Eth2Digest): T = @@ -508,24 +509,21 @@ proc doCreateTestnet*(config: CliConfig, writeFile(bootstrapFile, enr.toURI) echo "Wrote ", bootstrapFile -proc deployContract(web3: Web3, code: string): Future[ReceiptObject] {.async.} = - var code = code - if code[1] notin {'x', 'X'}: - code = "0x" & code +proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = EthSend( - source: web3.defaultAccount, + `from`: web3.defaultAccount, data: code, gas: Quantity(3000000).some, - gasPrice: 1.some) + gasPrice: Quantity(1).some) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = EthSend( - source: web3.defaultAccount, + `from`: web3.defaultAccount, gas: Quantity(3000000).some, - gasPrice: 1.some, + gasPrice: Quantity(1).some, value: some(valueEth.u256 * 1000000000000000000.u256), to: some(to)) web3.send(tr) diff --git a/research/fakeee.nim b/research/fakeee.nim index 41c0eab95..c01e40b5f 100644 --- a/research/fakeee.nim +++ b/research/fakeee.nim @@ -13,7 +13,7 @@ import std/typetraits, stew/byteutils, json_rpc/[rpcserver, errors], - web3/[conversions, engine_api_types], + web3/[conversions, engine_api_types, eth_api_types], chronicles proc setupEngineAPI*(server: RpcServer) = diff --git a/tests/test_helpers.nim b/tests/test_helpers.nim index 10747697c..66aff1f06 100644 --- a/tests/test_helpers.nim +++ b/tests/test_helpers.nim @@ -11,7 +11,7 @@ import # Status libraries stew/bitops2, eth/common/eth_types as commonEthTypes, eth/common/eth_types_rlp, - web3/ethtypes, + web3/primitives, # Beacon chain internals ../beacon_chain/spec/[forks, helpers, state_transition], ../beacon_chain/spec/datatypes/[bellatrix, capella], diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc index 60c4c9b5f..a8731e91b 160000 --- a/vendor/nim-json-rpc +++ b/vendor/nim-json-rpc @@ -1 +1 @@ -Subproject commit 60c4c9b5f28b530d5d89fd14c337af1d86390a82 +Subproject commit a8731e91bc336d930ac66f985d3b88ed7cf2a7d7 diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 428b931e7..df0af1aca 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 428b931e7c4f1284b4272bc2c11fca2bd70991cd +Subproject commit df0af1aca64f6a1a9a76c92776ce2b2ee0c6bfec