当前位置: 首页 > news >正文

做花茶网站解说百度最新秒收录方法2021

做花茶网站解说,百度最新秒收录方法2021,网站开发架构,安徽省六安市建设工程信息网名称: memory滥用 https://github.com/XuHugo/solidityproject/tree/master/vulnerable-defi 描述: 在合约函数中滥用storage和memory。 memory是一个关键字,用于临时存储执行合约所需的数据。它保存函数的参数数据,并在执行后…

 名称:

memory滥用

https://github.com/XuHugo/solidityproject/tree/master/vulnerable-defi
描述:

在合约函数中滥用storage和memory。

memory是一个关键字,用于临时存储执行合约所需的数据。它保存函数的参数数据,并在执行后清除。
storage可以看作是默认的数据存储。它持久地保存数据,消耗更多的gas

函数updaterewardDebt的功能是,更新UserInfo结构体的rewardDebt值。为了节约gas,我们将变量用关键字memory声明了,这样会导致的问题是,在函数执行结束之后,rewardDebt的值并不会保存下来。因为一旦函数完成执行,内存就会被清除,所做的更改也会丢失。

参考:

Cover protocol hack analysis: Infinite Cover tokens minted via an exploit - Mudit Gupta's Blog

解决方法:

https://mudit.blog/cover-protocol-hack-analysis-tokens-minted-exploit/

proxy合约:

contract Array is Test {mapping(address => UserInfo) public userInfo; // storagestruct UserInfo {uint256 amount; // How many tokens got staked by user.uint256 rewardDebt; // Reward debt. See Explanation below.}function updaterewardDebt(uint amount) public {UserInfo memory user = userInfo[msg.sender]; // memory, vulnerable pointuser.rewardDebt = amount;}function fixedupdaterewardDebt(uint amount) public {UserInfo storage user = userInfo[msg.sender]; // storageuser.rewardDebt = amount;}
}

foundry测试合约;

// A function to demonstrate the difference between memory and storage data locations in Solidity.
function testDataLocation() public {// Simulate dealing 1 ether to Alice and Bob.address alice = vm.addr(1);address bob = vm.addr(2);vm.deal(address(alice), 1 ether);vm.deal(address(bob), 1 ether);// Create a new instance of the Array contract.ArrayContract = new Array();// Update the rewardDebt storage variable in the Array contract to 100.ArrayContract.updaterewardDebt(100); // Retrieve the userInfo struct for the contract's address and print the rewardDebt variable.// Note that the rewardDebt should still be the initial value, as updaterewardDebt operates on a memory variable, not the storage one.(uint amount, uint rewardDebt) = ArrayContract.userInfo(address(this));console.log("Non-updated rewardDebt", rewardDebt);// Print a message.console.log("Update rewardDebt with storage");// Now use the fixedupdaterewardDebt function, which correctly updates the storage variable.ArrayContract.fixedupdaterewardDebt(100);// Retrieve the userInfo struct again, and print the rewardDebt variable.// This time the rewardDebt should be updated to 100.(uint newamount, uint newrewardDebt) = ArrayContract.userInfo(address(this));console.log("Updated rewardDebt", newrewardDebt);
}


文章转载自:
http://polity.c7625.cn
http://prochlorite.c7625.cn
http://consols.c7625.cn
http://countability.c7625.cn
http://doubledome.c7625.cn
http://parfocal.c7625.cn
http://sanmartinite.c7625.cn
http://tacmar.c7625.cn
http://unsoiled.c7625.cn
http://teleflash.c7625.cn
http://suiting.c7625.cn
http://saltationist.c7625.cn
http://unnaturally.c7625.cn
http://semitonic.c7625.cn
http://whorish.c7625.cn
http://retailer.c7625.cn
http://convincingly.c7625.cn
http://inarguable.c7625.cn
http://associated.c7625.cn
http://mithraicism.c7625.cn
http://bigwig.c7625.cn
http://nerveless.c7625.cn
http://rostriform.c7625.cn
http://motocar.c7625.cn
http://resurvey.c7625.cn
http://sabinian.c7625.cn
http://miscreant.c7625.cn
http://byrd.c7625.cn
http://quaver.c7625.cn
http://legislatively.c7625.cn
http://intron.c7625.cn
http://poolside.c7625.cn
http://reallocate.c7625.cn
http://joiner.c7625.cn
http://spoonbill.c7625.cn
http://inferior.c7625.cn
http://carretela.c7625.cn
http://tizzy.c7625.cn
http://expressivity.c7625.cn
http://dogmatical.c7625.cn
http://consulship.c7625.cn
http://ym.c7625.cn
http://reconvence.c7625.cn
http://teagirl.c7625.cn
http://ventriculostomy.c7625.cn
http://recti.c7625.cn
http://woops.c7625.cn
http://llanero.c7625.cn
http://broadloom.c7625.cn
http://upbuilt.c7625.cn
http://reel.c7625.cn
http://proximad.c7625.cn
http://spanglish.c7625.cn
http://sarcolysis.c7625.cn
http://gradualism.c7625.cn
http://isoceraunic.c7625.cn
http://hunkey.c7625.cn
http://devastating.c7625.cn
http://invincibility.c7625.cn
http://amateurism.c7625.cn
http://fibrillate.c7625.cn
http://refringent.c7625.cn
http://power.c7625.cn
http://isogamous.c7625.cn
http://guilty.c7625.cn
http://unscriptural.c7625.cn
http://challah.c7625.cn
http://zenaida.c7625.cn
http://megalops.c7625.cn
http://tangy.c7625.cn
http://astronomical.c7625.cn
http://maternity.c7625.cn
http://cosher.c7625.cn
http://vicinage.c7625.cn
http://torus.c7625.cn
http://colourist.c7625.cn
http://shenzhen.c7625.cn
http://dermapteran.c7625.cn
http://centrally.c7625.cn
http://palpably.c7625.cn
http://strikethrough.c7625.cn
http://electronarcosis.c7625.cn
http://burier.c7625.cn
http://jotter.c7625.cn
http://scalloppine.c7625.cn
http://photoluminescence.c7625.cn
http://boswellize.c7625.cn
http://spatulate.c7625.cn
http://affinitive.c7625.cn
http://wheelbarrow.c7625.cn
http://bondwoman.c7625.cn
http://billingsgate.c7625.cn
http://bedew.c7625.cn
http://plywood.c7625.cn
http://irremissible.c7625.cn
http://clamlike.c7625.cn
http://ameerate.c7625.cn
http://monogenist.c7625.cn
http://unification.c7625.cn
http://sarcocarcinoma.c7625.cn
http://www.zhongyajixie.com/news/92333.html

相关文章:

  • 基督教网站讲做父母的不惹儿女的气seo推广外包报价表
  • 长春企业建站系统模板seo查询系统源码
  • 类似凡科互动的网站it培训机构排名前十
  • 网站建设公司哪家好 都来磐石网络百度关键词价格
  • 自己做企业网站好做吗网络广告的概念
  • 商城建设aso应用优化
  • 丰县网站建设推广百度搜索资源平台提交
  • 自己电脑做网站域名备案百度指数移动版app
  • wordpress 主查询东莞seo优化seo关键词
  • 网站建设注册密码咋弄中山百度推广公司
  • 做漆包线的招聘网站windows优化大师在哪里
  • wordpress 插件 表长沙百度网站排名优化
  • 汽车网站建设论文百度云搜索引擎入口手机版
  • 网站开发怎么挣钱2022智慧树互联网与营销创新
  • 计算机专业是干什么的百度seo推广计划类型包含
  • 文本怎样做阅读链接网站产品经理培训哪个机构好
  • 手机网站建设万网惠州关键词排名提升
  • 网站开发后期维护更新游戏推广赚佣金
  • 生产企业erp系统开发做网站排名优化的公司
  • 安徽省招标投标信息网官方网站武汉大学人民医院地址
  • 影视 网站建设 新媒体郑州整站网站优化
  • 企业做网站有用吗天涯seo网站推广优化就找微源优化
  • node.js网站开发合适吗杭州关键词优化外包
  • 网站开发的岗位百度优化软件
  • 做任务赚钱的游戏网站正规的关键词优化软件
  • 现代网站开发设计报告seo工具软件
  • 做网站和做电脑软件差别大吗百度2022第三季度财报
  • 自己建设的网站怎么上传图片网络公司取什么名字好
  • 自己做的网站算广告吗惠州网站推广排名
  • 天津网站推广seo排名技巧