Skip to content

Commit

Permalink
feat: impl tron's buggy origin opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Nov 4, 2020
1 parent a0b1d33 commit bf4080d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runtime/src/eval/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ pub fn selfbalance<H: Handler>(runtime: &mut Runtime, handler: &H) -> Control<H>
}

pub fn origin<H: Handler>(runtime: &mut Runtime, handler: &H) -> Control<H> {
let ret = H256::from(handler.origin());
// TRON: Use 21-byte address before allowMultisig.
let mut ret = H256::from(handler.origin());
if runtime._config.has_buggy_origin {
ret.as_bytes_mut()[11] = 0x41;
}
push!(runtime, ret);

Control::Continue
Expand Down
5 changes: 5 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ pub struct Config {
pub has_token_issue: bool,
/// Has iswitness. (renamed from issrcandidate)
pub has_iswitness: bool,
/// Has a buggy origin opcode. (21 bytes origin address)
pub has_buggy_origin: bool,
}

impl Config {
Expand Down Expand Up @@ -305,6 +307,7 @@ impl Config {
has_stake: false,
has_token_issue: false,
has_iswitness: false,
has_buggy_origin: true,
}
}
/// Frontier hard fork configuration.
Expand Down Expand Up @@ -352,6 +355,7 @@ impl Config {
has_stake: false,
has_token_issue: false,
has_iswitness: false,
has_buggy_origin: false,
}
}

Expand Down Expand Up @@ -400,6 +404,7 @@ impl Config {
has_stake: false,
has_token_issue: false,
has_iswitness: false,
has_buggy_origin: false,
}
}
}

0 comments on commit bf4080d

Please sign in to comment.