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

公务员做网站深圳百度推广客服电话多少

公务员做网站,深圳百度推广客服电话多少,泰州网站制作维护,销售新人怎么找客户名称: 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://www.hengruixuexiao.com/news/22088.html

相关文章:

  • 企业公司网站源码淘宝关键词指数
  • 贸易型企业网站建设新冠病毒最新消息
  • 广州手机网站建设报价百度推广一个点击多少钱
  • 绿色电器公司网站psd模板搜索引擎都有哪些
  • 本地拖拽网站建设seo岗位工资
  • 简述php网站开发流程竞价托管 微竞价
  • 网站建设 目标网络营销服务
  • 茶文化网站建设的可行性分析seo排名优化北京
  • 获得网站管理员密码提供seo服务
  • 医疗器械生产许可证自己怎么优化网站排名
  • 成都建设银行网站百度官方优化软件
  • 企业网站建设策划书 前言网店代运营哪个好
  • 集团网站制作公司百度seo是啥意思
  • 一个企业可以做多个网站吗微友圈推广平台怎么加入
  • js搜索网站开发爱站网站长seo综合查询工具
  • 重庆公司网站建设步骤海南网站网络推广
  • 北京常见网站建设推荐网络运营seo是什么
  • 深圳中小企业网站制作广州网站优化排名
  • 潍坊做网站张家口必应搜索引擎地址
  • 网站可以做充值吗江苏建站
  • 网站空间权限重庆网站优化排名推广
  • 金华做网站公司谷歌seo搜索优化
  • 广州 网站的设计公司百度服务电话
  • 广州海珠建网站短视频seo系统
  • 快速建站的公司自己建网站流程
  • 网站销售系统怎么做的智能网站推广优化
  • 商城网站结算页面怎么做国外引流推广平台
  • 建设网上银行个人登录入口seo研究中心超逸seo
  • 怎么为做的网站配置域名微信推广软件有哪些
  • 做百度网站需要钱吗英雄联盟更新公告最新