Skip to content

Commit fcf0ce4

Browse files
JonathanOppenheimerceyonurARR4NStephenButtolph
authored
Add precompile reversion logic for Granite activation (#1149)
Signed-off-by: Jonathan Oppenheimer <jonathan.oppenheimer@avalabs.org> Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com> Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org> Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com> Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
1 parent fe2ab9d commit fcf0ce4

File tree

2 files changed

+191
-113
lines changed

2 files changed

+191
-113
lines changed

params/hooks_libevm.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
// invalidateDelegateTime is the Unix timestamp for August 2nd, 2025, midnight Eastern Time
3131
// (August 2nd, 2025, 04:00 UTC)
32-
const invalidateDelegateUnix = 1754107200
32+
const InvalidateDelegateUnix = 1754107200
3333

3434
// P256VerifyAddress is the address of the p256 signature verification precompile
3535
var P256VerifyAddress = common.BytesToAddress([]byte{0x1, 0x00})
@@ -139,12 +139,14 @@ func makePrecompile(contract contract.StatefulPrecompiledContract) libevm.Precom
139139
},
140140
}
141141

142-
callType := env.IncomingCallType()
143-
isDissallowedCallType := callType == vm.DelegateCall || callType == vm.CallCode
144-
if env.BlockTime() >= invalidateDelegateUnix {
145-
if isDissallowedCallType {
146-
env.InvalidateExecution(fmt.Errorf("precompile cannot be called with %s", callType))
147-
}
142+
switch call := env.IncomingCallType(); {
143+
case call != vm.DelegateCall && call != vm.CallCode: // Others always allowed
144+
case rules.IsGranite:
145+
return nil, 0, vm.ErrExecutionReverted
146+
case env.BlockTime() >= InvalidateDelegateUnix:
147+
env.InvalidateExecution(fmt.Errorf("precompile cannot be called with %s", call))
148+
default:
149+
// Otherwise, we allow the precompile to be called
148150
}
149151

150152
// EVM semantic addresses are used here to maintain consistency with prior behavior as present in AvalancheGo 1.13.0.

0 commit comments

Comments
 (0)